Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
appinventor-sources
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
appinventor-sources
Commits
3e94ebc7
Unverified
Commit
3e94ebc7
authored
Mar 10, 2020
by
Conor Shipp
Committed by
GitHub
Mar 10, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Reverse Text Block (#1998)
Co-authored-by:
Evan W. Patton
<
ewpatton@mit.edu
>
parent
40f66fc1
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
80 additions
and
3 deletions
+80
-3
appinventor/blocklyeditor/src/blocks/text.js
appinventor/blocklyeditor/src/blocks/text.js
+15
-0
appinventor/blocklyeditor/src/generators/yail/text.js
appinventor/blocklyeditor/src/generators/yail/text.js
+16
-0
appinventor/blocklyeditor/src/msg/en/_messages.js
appinventor/blocklyeditor/src/msg/en/_messages.js
+4
-0
appinventor/blocklyeditor/src/versioning.js
appinventor/blocklyeditor/src/versioning.js
+4
-1
appinventor/buildserver/src/com/google/appinventor/buildserver/resources/runtime.scm
.../com/google/appinventor/buildserver/resources/runtime.scm
+15
-0
appinventor/buildserver/tests/com/google/appinventor/buildserver/YailEvalTest.java
...ests/com/google/appinventor/buildserver/YailEvalTest.java
+6
-0
appinventor/components/src/com/google/appinventor/components/common/YaVersion.java
...c/com/google/appinventor/components/common/YaVersion.java
+6
-2
appinventor/docs/html/reference/blocks/images/text/text_reverse.png
...r/docs/html/reference/blocks/images/text/text_reverse.png
+0
-0
appinventor/docs/html/reference/blocks/text.html
appinventor/docs/html/reference/blocks/text.html
+7
-0
appinventor/docs/markdown/reference/blocks/images/text/text_reverse.png
...cs/markdown/reference/blocks/images/text/text_reverse.png
+0
-0
appinventor/docs/markdown/reference/blocks/text.md
appinventor/docs/markdown/reference/blocks/text.md
+7
-0
No files found.
appinventor/blocklyeditor/src/blocks/text.js
View file @
3e94ebc7
...
...
@@ -497,3 +497,18 @@ Blockly.Blocks['text_is_string'] = {
},
typeblock
:
[{
translatedName
:
Blockly
.
Msg
.
LANG_TEXT_TEXT_IS_STRING_TITLE
}]
};
Blockly
.
Blocks
[
'
text_reverse
'
]
=
{
// String reverse.
category
:
'
Text
'
,
helpUrl
:
Blockly
.
Msg
.
LANG_TEXT_REVERSE_HELPURL
,
init
:
function
()
{
this
.
setColour
(
Blockly
.
TEXT_CATEGORY_HUE
);
this
.
setOutput
(
true
,
Blockly
.
Blocks
.
Utilities
.
YailTypeToBlocklyType
(
"
text
"
,
Blockly
.
Blocks
.
Utilities
.
OUTPUT
));
this
.
appendValueInput
(
'
VALUE
'
)
.
setCheck
(
Blockly
.
Blocks
.
Utilities
.
YailTypeToBlocklyType
(
"
text
"
,
Blockly
.
Blocks
.
Utilities
.
INPUT
))
.
appendField
(
Blockly
.
Msg
.
LANG_TEXT_REVERSE_INPUT
);
this
.
setTooltip
(
Blockly
.
Msg
.
LANG_TEXT_REVERSE_TOOLTIP
);
},
typeblock
:
[{
translatedName
:
Blockly
.
Msg
.
LANG_TEXT_REVERSE_INPUT
}]
};
appinventor/blocklyeditor/src/generators/yail/text.js
View file @
3e94ebc7
...
...
@@ -318,3 +318,19 @@ Blockly.Yail['text_is_string'] = function() {
code
=
code
+
Blockly
.
Yail
.
YAIL_DOUBLE_QUOTE
+
"
is a string?
"
+
Blockly
.
Yail
.
YAIL_DOUBLE_QUOTE
+
Blockly
.
Yail
.
YAIL_CLOSE_COMBINATION
;
return
[
code
,
Blockly
.
Yail
.
ORDER_ATOMIC
];
};
Blockly
.
Yail
[
'
text_reverse
'
]
=
function
()
{
// String reverse.
var
argument
=
Blockly
.
Yail
.
valueToCode
(
this
,
'
VALUE
'
,
Blockly
.
Yail
.
ORDER_NONE
)
||
"
\"\"
"
;
var
code
=
Blockly
.
Yail
.
YAIL_CALL_YAIL_PRIMITIVE
+
"
string-reverse
"
+
Blockly
.
Yail
.
YAIL_SPACER
;
code
=
code
+
Blockly
.
Yail
.
YAIL_OPEN_COMBINATION
+
Blockly
.
Yail
.
YAIL_LIST_CONSTRUCTOR
+
Blockly
.
Yail
.
YAIL_SPACER
+
argument
+
Blockly
.
Yail
.
YAIL_CLOSE_COMBINATION
;
code
=
code
+
Blockly
.
Yail
.
YAIL_SPACER
+
Blockly
.
Yail
.
YAIL_QUOTE
+
Blockly
.
Yail
.
YAIL_OPEN_COMBINATION
+
"
text
"
+
Blockly
.
Yail
.
YAIL_CLOSE_COMBINATION
+
Blockly
.
Yail
.
YAIL_SPACER
;
code
=
code
+
Blockly
.
Yail
.
YAIL_DOUBLE_QUOTE
+
"
reverse
"
+
Blockly
.
Yail
.
YAIL_DOUBLE_QUOTE
+
Blockly
.
Yail
.
YAIL_CLOSE_COMBINATION
;
return
[
code
,
Blockly
.
Yail
.
ORDER_ATOMIC
];
};
appinventor/blocklyeditor/src/msg/en/_messages.js
View file @
3e94ebc7
...
...
@@ -758,6 +758,10 @@ Blockly.Msg.en.switch_language_to_english = {
Blockly
.
Msg
.
LANG_TEXT_TEXT_IS_STRING_INPUT_THING
=
'
thing
'
;
Blockly
.
Msg
.
LANG_TEXT_TEXT_IS_STRING_TOOLTIP
=
'
Returns true if <code>thing</code> is a string.
'
;
Blockly
.
Msg
.
LANG_TEXT_REVERSE_HELPURL
=
'
/reference/blocks/text.html#reverse
'
;
Blockly
.
Msg
.
LANG_TEXT_REVERSE_INPUT
=
'
reverse
'
;
Blockly
.
Msg
.
LANG_TEXT_REVERSE_TOOLTIP
=
'
Reverse the given text.
'
;
// Lists Blocks.
Blockly
.
Msg
.
LANG_CATEGORY_LISTS
=
'
Lists
'
;
//Blockly.Msg.LANG_LISTS_CREATE_EMPTY_HELPURL = 'http://en.wikipedia.org/wiki/Linked_list.html#Empty_lists';
...
...
appinventor/blocklyeditor/src/versioning.js
View file @
3e94ebc7
...
...
@@ -1813,7 +1813,10 @@ Blockly.Versioning.AllUpgradeMaps =
28
:
"
noUpgrade
"
,
// AI2: Added "for each in dictionary" block.
29
:
"
noUpgrade
"
29
:
"
noUpgrade
"
,
// AI2: In BLOCKS_LANGUAGE_VERSION 30, The Reverse Text block was added
30
:
"
noUpgrade
"
},
// End Language upgraders
...
...
appinventor/buildserver/src/com/google/appinventor/buildserver/resources/runtime.scm
View file @
3e94ebc7
...
...
@@ -1872,6 +1872,21 @@
(
define
(
string-to-lower-case
s
)
(
String:toLowerCase
(
s:toString
)))
(
define
(
unicode-string->list
str
::
<string>
)
::
<list>
(
let
loop
((
result
::
<list>
'
())
(
i
::
<int>
(
string-length
str
)))
(
set!
i
(
-
i
1
))
(
if
(
<
i
0
)
result
(
if
(
and
(
>=
i
1
)
(
let
((
c
(
string-ref
str
i
))
(
c1
(
string-ref
str
(
-
i
1
))))
(
and
(
char>=?
c
#\xD800
)
(
char<=?
c
#\xDFFF
)
(
char>=?
c1
#\xD800
)
(
char<=?
c1
#\xDFFF
))))
(
loop
(
make
<pair>
(
string-ref
str
i
)
(
make
<pair>
(
string-ref
str
(
-
i
1
))
result
))
(
-
i
1
))
(
loop
(
make
<pair>
(
string-ref
str
i
)
result
)
i
)))))
(
define
(
string-reverse
s
)
(
list->string
(
reverse
(
unicode-string->list
s
))))
;;; returns a string that is the number formatted with a
;;; specified number of decimal places
(
define
(
format-as-decimal
number
places
)
...
...
appinventor/buildserver/tests/com/google/appinventor/buildserver/YailEvalTest.java
View file @
3e94ebc7
...
...
@@ -77,6 +77,12 @@ public class YailEvalTest extends TestCase {
scheme
.
eval
(
thunkify
(
schemeString
)).
toString
());
}
public
void
testStringReverse
()
throws
Throwable
{
assertEquals
(
"raboof"
,
(
scheme
.
eval
(
"(string-reverse \"foobar\")"
)).
toString
());
assertEquals
(
"\uD83D\uDE43\uD83D\uDE0F\uD83E\uDD29\uD83D\uDE02\uD83D\uDC4F\uD83D\uDE03\uD83D\uDC4D\uD83D\uDE18"
,
(
scheme
.
eval
(
"(string-reverse \"\uD83D\uDE18\uD83D\uDC4D\uD83D\uDE03\uD83D\uDC4F\uD83D\uDE02\uD83E\uDD29\uD83D\uDE0F\uD83D\uDE43\")"
)).
toString
());
}
/**
* This is mostly here as a workaround for some strange behavior with top-level try-catch
* expressions in Kawa.
...
...
appinventor/components/src/com/google/appinventor/components/common/YaVersion.java
View file @
3e94ebc7
...
...
@@ -499,8 +499,10 @@ public class YaVersion {
// - FORM_COMPONENT_VERSION was incremented to 27.
// For YOUNG_ANDROID_VERSION 201:
// - CANVAS_COMPONENT_VERSION was incremented to 13
// For YOUNG_ANDROID_VERSION 202:
// - BLOCKS_LANGUAGE_VERSION was incremented to 30
public
static
final
int
YOUNG_ANDROID_VERSION
=
20
1
;
public
static
final
int
YOUNG_ANDROID_VERSION
=
20
2
;
// ............................... Blocks Language Version Number ...............................
...
...
@@ -576,8 +578,10 @@ public class YaVersion {
// - The dictionaries blocks were added.
// For BLOCKS_LANGUAGE_VERSION 29
// - The for-each-in-dictionary block was added.
// For BLOCKS_LANGUAGE_VERSION 30:
// - The Reverse Text block was added
public
static
final
int
BLOCKS_LANGUAGE_VERSION
=
29
;
public
static
final
int
BLOCKS_LANGUAGE_VERSION
=
30
;
// ................................. Target SDK Version Number ..................................
...
...
appinventor/docs/html/reference/blocks/images/text/text_reverse.png
0 → 100644
View file @
3e94ebc7
1.4 KB
appinventor/docs/html/reference/blocks/text.html
View file @
3e94ebc7
...
...
@@ -145,6 +145,7 @@
<li><a
href=
"#replaceall"
>
replace all
</a></li>
<li><a
href=
"#obfuscatetext"
>
obfuscated text
</a></li>
<li><a
href=
"#isstring"
>
is a string?
</a></li>
<li><a
href=
"#reverse"
>
reverse
</a></li>
</ul>
<h3
id=
"string"
>
” “ (string block)
</h3>
...
...
@@ -273,6 +274,12 @@
<p>
Returns true if
<em>
thing
</em>
is a text object, otherwise false.
</p>
<h3
id=
"reverse"
>
reverse
</h3>
<p><img
src=
"images/text/text_reverse.png"
alt=
""
/></p>
<p>
Reverse the given text. For example, “reverse” would become “esrever”.
</p>
</article>
<script>
// Handle redirection to documentation based on locale query parameter (if specified)
...
...
appinventor/docs/markdown/reference/blocks/images/text/text_reverse.png
0 → 100644
View file @
3e94ebc7
1.4 KB
appinventor/docs/markdown/reference/blocks/text.md
View file @
3e94ebc7
...
...
@@ -22,6 +22,7 @@ layout: documentation
*
[
replace all
](
#replaceall
)
*
[
obfuscated text
](
#obfuscatetext
)
*
[
is a string?
](
#isstring
)
*
[
reverse
](
#reverse
)
### " " (string block) {#string}
...
...
@@ -148,3 +149,9 @@ Produces text, like a text block. The difference is that th etext is not easily
![](
images/text/isstring.png
)
Returns true if
*thing*
is a text object, otherwise false.
### reverse {#reverse}
![](
images/text/text_reverse.png
)
Reverse the given text. For example, "reverse" would become "esrever".
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment