|
@@ -717,24 +717,29 @@ smalltalk.addMethod(
|
|
smalltalk.method({
|
|
smalltalk.method({
|
|
selector: "print:",
|
|
selector: "print:",
|
|
category: 'actions',
|
|
category: 'actions',
|
|
-fn: function (aString) {
|
|
|
|
- var self = this;
|
|
|
|
- var start;
|
|
|
|
- var stop;
|
|
|
|
- start = smalltalk.send(smalltalk.HashedCollection || HashedCollection, "_new", []);
|
|
|
|
- stop = smalltalk.send(smalltalk.HashedCollection || HashedCollection, "_new", []);
|
|
|
|
- smalltalk.send(start, "_at_put_", ["line", smalltalk.send(smalltalk.send(self['@editor'], "_getCursor_", [false]), "_line", [])]);
|
|
|
|
- smalltalk.send(start, "_at_put_", ["ch", smalltalk.send(smalltalk.send(self['@editor'], "_getCursor_", [false]), "_ch", [])]);
|
|
|
|
- smalltalk.send(stop, "_at_put_", ["line", smalltalk.send(start, "_at_", ["line"])]);
|
|
|
|
- smalltalk.send(stop, "_at_put_", ["ch", smalltalk.send(smalltalk.send(smalltalk.send(start, "_at_", ["ch"]), "__plus", [smalltalk.send(aString, "_size", [])]), "__plus", [2])]);
|
|
|
|
- smalltalk.send(self['@editor'], "_replaceSelection_", [smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(self['@editor'], "_getSelection", []), "__comma", [" "]), "__comma", [aString]), "__comma", [" "])]);
|
|
|
|
- smalltalk.send(self['@editor'], "_setCursor_", [smalltalk.send(self['@editor'], "_getCursor_", [true])]);
|
|
|
|
- smalltalk.send(self['@editor'], "_setSelection_end_", [stop, start]);
|
|
|
|
- return self;
|
|
|
|
-},
|
|
|
|
|
|
+fn: function (aString){
|
|
|
|
+var self=this;
|
|
|
|
+var start;
|
|
|
|
+var stop;
|
|
|
|
+var currentLine;
|
|
|
|
+currentLine=smalltalk.send(smalltalk.send(self["@editor"],"_getCursor_",[false]),"_line",[]);
|
|
|
|
+start=smalltalk.send((smalltalk.HashedCollection || HashedCollection),"_new",[]);
|
|
|
|
+smalltalk.send(start,"_at_put_",["line",currentLine]);
|
|
|
|
+smalltalk.send(start,"_at_put_",["ch",smalltalk.send(smalltalk.send(self["@editor"],"_getCursor_",[false]),"_ch",[])]);
|
|
|
|
+smalltalk.send(smalltalk.send(self["@editor"],"_getSelection",[]),"_ifEmpty_",[(function(){
|
|
|
|
+smalltalk.send(start,"_at_put_",["ch",smalltalk.send(smalltalk.send(self["@editor"],"_getLine_",[currentLine]),"_size",[])]);
|
|
|
|
+return smalltalk.send(self["@editor"],"_setSelection_end_",[smalltalk.HashedCollection._fromPairs_([smalltalk.send("line","__minus_gt",[currentLine]),smalltalk.send("ch","__minus_gt",[(0)])]),start]);
|
|
|
|
+})]);
|
|
|
|
+stop=smalltalk.send((smalltalk.HashedCollection || HashedCollection),"_new",[]);
|
|
|
|
+smalltalk.send(stop,"_at_put_",["line",currentLine]);
|
|
|
|
+smalltalk.send(stop,"_at_put_",["ch",smalltalk.send(smalltalk.send(smalltalk.send(start,"_at_",["ch"]),"__plus",[smalltalk.send(aString,"_size",[])]),"__plus",[(2)])]);
|
|
|
|
+smalltalk.send(self["@editor"],"_replaceSelection_",[smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(self["@editor"],"_getSelection",[]),"__comma",[" "]),"__comma",[aString]),"__comma",[" "])]);
|
|
|
|
+smalltalk.send(self["@editor"],"_setCursor_",[smalltalk.send(self["@editor"],"_getCursor_",[true])]);
|
|
|
|
+smalltalk.send(self["@editor"],"_setSelection_end_",[stop,start]);
|
|
|
|
+return self},
|
|
args: ["aString"],
|
|
args: ["aString"],
|
|
-source: "print: aString\x0a\x09| start stop |\x0a\x09start := HashedCollection new.\x0a\x09stop := HashedCollection new.\x0a\x09start at: 'line' put: (editor getCursor: false) line.\x0a\x09start at: 'ch' put: (editor getCursor: false) ch.\x0a\x09stop at: 'line' put: (start at: 'line').\x0a\x09stop at: 'ch' put: ((start at: 'ch') + aString size + 2).\x0a\x09editor replaceSelection: (editor getSelection, ' ', aString, ' ').\x0a\x09editor setCursor: (editor getCursor: true).\x0a\x09editor setSelection: stop end: start",
|
|
|
|
-messageSends: ["new", "at:put:", "line", "getCursor:", "ch", "at:", "+", "size", "replaceSelection:", ",", "getSelection", "setCursor:", "setSelection:end:"],
|
|
|
|
|
|
+source: "print: aString\x0a\x09| start stop currentLine |\x0a currentLine := (editor getCursor: false) line.\x0a\x09start := HashedCollection new.\x0a\x09start at: 'line' put: currentLine.\x0a\x09start at: 'ch' put: (editor getCursor: false) ch.\x0a (editor getSelection) ifEmpty: [\x0a \x09\x22select current line if selection is empty\x22\x0a \x09start at: 'ch' put: (editor getLine: currentLine) size.\x0a editor setSelection: #{'line' -> currentLine. 'ch' -> 0} end: start.\x0a ].\x0a\x09stop := HashedCollection new.\x0a\x09stop at: 'line' put: currentLine.\x0a\x09stop at: 'ch' put: ((start at: 'ch') + aString size + 2).\x0a\x0a\x09editor replaceSelection: (editor getSelection, ' ', aString, ' ').\x0a\x09editor setCursor: (editor getCursor: true).\x0a\x09editor setSelection: stop end: start",
|
|
|
|
+messageSends: ["line", "getCursor:", "new", "at:put:", "ch", "ifEmpty:", "size", "getLine:", "setSelection:end:", "->", "getSelection", "+", "at:", "replaceSelection:", ",", "setCursor:"],
|
|
referencedClasses: ["HashedCollection"]
|
|
referencedClasses: ["HashedCollection"]
|
|
}),
|
|
}),
|
|
smalltalk.SourceArea);
|
|
smalltalk.SourceArea);
|