Browse Source

Use codeMirror lib via imports.

Herby Vojčík 5 years ago
parent
commit
c75cda1ab7
2 changed files with 28 additions and 59 deletions
  1. 18 43
      src/Helios-Workspace.js
  2. 10 16
      src/Helios-Workspace.st

+ 18 - 43
src/Helios-Workspace.js

@@ -1484,7 +1484,7 @@ var self=this,$self=this;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-$self["@editor"] = $self._class()._codeMirror().fromTextArea(aTextarea, $self._editorOptions());
+$self["@editor"] = codeMirrorLib.fromTextArea(aTextarea, $self._editorOptions());
 return self;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx1) {$ctx1.fill(self,"setEditorOn:",{aTextarea:aTextarea},$globals.HLCodeWidget)});
@@ -1492,7 +1492,7 @@ return self;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["aTextarea"],
-source: "setEditorOn: aTextarea\x0a\x09<inlineJS: '$self[\x22@editor\x22] = $self._class()._codeMirror().fromTextArea(aTextarea, $self._editorOptions())'>",
+source: "setEditorOn: aTextarea\x0a\x09<inlineJS: '$self[\x22@editor\x22] = codeMirrorLib.fromTextArea(aTextarea, $self._editorOptions())'>",
 referencedClasses: [],
 //>>excludeEnd("ide");
 messageSends: []
@@ -1615,45 +1615,21 @@ messageSends: ["collect:", "get", "find:", "asJQuery", "wrapper", "display", "ht
 $globals.HLCodeWidget);
 
 
-$core.addMethod(
-$core.method({
-selector: "codeMirror",
-protocol: "accessing",
-fn: function (){
-var self=this,$self=this;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx1) {
-//>>excludeEnd("ctx");
-return $recv(require)._value_("codemirror/lib/codemirror");
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"codeMirror",{},$globals.HLCodeWidget.a$cls)});
-//>>excludeEnd("ctx");
-},
-//>>excludeStart("ide", pragmas.excludeIdeData);
-args: [],
-source: "codeMirror\x0a\x09^ require value: 'codemirror/lib/codemirror'",
-referencedClasses: [],
-//>>excludeEnd("ide");
-messageSends: ["value:"]
-}),
-$globals.HLCodeWidget.a$cls);
-
 $core.addMethod(
 $core.method({
 selector: "hintFor:options:",
 protocol: "hints",
 fn: function (anEditor,options){
 var self=this,$self=this;
-var cursor,token,completions,codeMirror;
+var cursor,token,completions;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
 var $1,$4,$3,$2,$5,$6,$8,$9,$7;
-codeMirror=$self._codeMirror();
 cursor=$recv(anEditor)._getCursor();
 token=$recv(anEditor)._getTokenAt_(cursor);
 $1=token;
-$4=$recv(codeMirror)._basicAt_("innerMode");
+$4=$recv(codeMirrorLib)._basicAt_("innerMode");
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 $ctx1.sendIdx["basicAt:"]=1;
 //>>excludeEnd("ctx");
@@ -1670,7 +1646,7 @@ completions=$recv($globals.HLCodeWidget)._variableHintFor_token_(anEditor,token)
 completions=$recv($globals.HLCodeWidget)._messageHintFor_token_(anEditor,token);
 }
 $6=completions;
-$8=$recv(codeMirror)._basicAt_("Pos");
+$8=$recv(codeMirrorLib)._basicAt_("Pos");
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 $ctx1.sendIdx["basicAt:"]=2;
 //>>excludeEnd("ctx");
@@ -1682,17 +1658,17 @@ $7=$recv($8)._value_value_($9,$recv(token)._end());
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 $ctx1.sendIdx["value:value:"]=2;
 //>>excludeEnd("ctx");
-return $globals.HashedCollection._newFromPairs_(["list",$6,"from",$7,"to",$recv($recv(codeMirror)._basicAt_("Pos"))._value_value_($recv(cursor)._line(),$recv(token)._start())]);
+return $globals.HashedCollection._newFromPairs_(["list",$6,"from",$7,"to",$recv($recv(codeMirrorLib)._basicAt_("Pos"))._value_value_($recv(cursor)._line(),$recv(token)._start())]);
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"hintFor:options:",{anEditor:anEditor,options:options,cursor:cursor,token:token,completions:completions,codeMirror:codeMirror},$globals.HLCodeWidget.a$cls)});
+}, function($ctx1) {$ctx1.fill(self,"hintFor:options:",{anEditor:anEditor,options:options,cursor:cursor,token:token,completions:completions},$globals.HLCodeWidget.a$cls)});
 //>>excludeEnd("ctx");
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["anEditor", "options"],
-source: "hintFor: anEditor options: options\x0a\x09| cursor token completions codeMirror |\x0a\x09\x0a\x09codeMirror := self codeMirror.\x0a\x09cursor := anEditor getCursor.\x0a\x09token := anEditor getTokenAt: cursor.\x0a\x09token at: 'state' put: ((codeMirror basicAt: 'innerMode')\x0a\x09\x09value: anEditor getMode value: (token at: 'state')) state.\x0a\x09\x0a\x09completions := token type = 'variable' \x0a\x09\x09ifTrue: [ HLCodeWidget variableHintFor: anEditor token: token ]\x0a\x09\x09ifFalse: [ HLCodeWidget messageHintFor: anEditor token: token ].\x0a\x09\x0a\x09^ #{\x0a\x09\x09'list' -> completions.\x0a\x09\x09'from' -> ((codeMirror basicAt: 'Pos') value: cursor line value: token end).\x0a\x09\x09'to' -> ((codeMirror basicAt: 'Pos') value: cursor line value: token start)\x0a\x09}",
+source: "hintFor: anEditor options: options\x0a\x09| cursor token completions |\x0a\x09\x0a\x09cursor := anEditor getCursor.\x0a\x09token := anEditor getTokenAt: cursor.\x0a\x09token at: 'state' put: ((codeMirrorLib basicAt: 'innerMode')\x0a\x09\x09value: anEditor getMode value: (token at: 'state')) state.\x0a\x09\x0a\x09completions := token type = 'variable' \x0a\x09\x09ifTrue: [ HLCodeWidget variableHintFor: anEditor token: token ]\x0a\x09\x09ifFalse: [ HLCodeWidget messageHintFor: anEditor token: token ].\x0a\x09\x0a\x09^ #{\x0a\x09\x09'list' -> completions.\x0a\x09\x09'from' -> ((codeMirrorLib basicAt: 'Pos') value: cursor line value: token end).\x0a\x09\x09'to' -> ((codeMirrorLib basicAt: 'Pos') value: cursor line value: token start)\x0a\x09}",
 referencedClasses: ["HLCodeWidget"],
 //>>excludeEnd("ide");
-messageSends: ["codeMirror", "getCursor", "getTokenAt:", "at:put:", "state", "value:value:", "basicAt:", "getMode", "at:", "ifTrue:ifFalse:", "=", "type", "variableHintFor:token:", "messageHintFor:token:", "line", "end", "start"]
+messageSends: ["getCursor", "getTokenAt:", "at:put:", "state", "value:value:", "basicAt:", "getMode", "at:", "ifTrue:ifFalse:", "=", "type", "variableHintFor:token:", "messageHintFor:token:", "line", "end", "start"]
 }),
 $globals.HLCodeWidget.a$cls);
 
@@ -1828,10 +1804,9 @@ var self=this,$self=this;
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
 
-		var codeMirror = $self._codeMirror();
-		codeMirror.keyMap["default"].fallthrough = ["basic"];
-		codeMirror.commands.autocomplete = function(cm) {
-			codeMirror.showHint(cm, $self._hintFor_options_.bind($self));
+		codeMirrorLib.keyMap["default"].fallthrough = ["basic"];
+		codeMirrorLib.commands.autocomplete = function(cm) {
+			codeMirrorLib.showHint(cm, $self._hintFor_options_.bind($self));
 		}
 	;
 return self;
@@ -1841,7 +1816,7 @@ return self;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "setupCodeMirror\x0a\x09<inlineJS: '\x0a\x09\x09var codeMirror = $self._codeMirror();\x0a\x09\x09codeMirror.keyMap[\x22default\x22].fallthrough = [\x22basic\x22];\x0a\x09\x09codeMirror.commands.autocomplete = function(cm) {\x0a\x09\x09\x09codeMirror.showHint(cm, $self._hintFor_options_.bind($self));\x0a\x09\x09}\x0a\x09'>",
+source: "setupCodeMirror\x0a\x09<inlineJS: '\x0a\x09\x09codeMirrorLib.keyMap[\x22default\x22].fallthrough = [\x22basic\x22];\x0a\x09\x09codeMirrorLib.commands.autocomplete = function(cm) {\x0a\x09\x09\x09codeMirrorLib.showHint(cm, $self._hintFor_options_.bind($self));\x0a\x09\x09}\x0a\x09'>",
 referencedClasses: [],
 //>>excludeEnd("ide");
 messageSends: []
@@ -1858,7 +1833,7 @@ var self=this,$self=this;
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
 var $1,$2,$3,$4,$5;
-$1=$recv($self._codeMirror())._basicAt_("commands");
+$1=$recv(codeMirrorLib)._basicAt_("commands");
 $recv($1)._at_put_("doIt",(function(cm){
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx2) {
@@ -1939,10 +1914,10 @@ return self;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "setupCommands\x0a\x09(self codeMirror basicAt: 'commands') \x0a\x09\x09at: 'doIt' put: [ :cm | cm amberCodeWidget doIt ];\x0a\x09\x09at: 'inspectIt' put: [ :cm | cm amberCodeWidget inspectIt ];\x0a\x09\x09at: 'printIt' put: [ :cm | cm amberCodeWidget printIt ];\x0a\x09\x09at: 'saveIt' put: [ :cm | cm amberCodeWidget saveIt ];\x0a\x09\x09at: 'browseIt' put: [ :cm | cm amberCodeWidget browseIt ]",
+source: "setupCommands\x0a\x09(codeMirrorLib basicAt: 'commands') \x0a\x09\x09at: 'doIt' put: [ :cm | cm amberCodeWidget doIt ];\x0a\x09\x09at: 'inspectIt' put: [ :cm | cm amberCodeWidget inspectIt ];\x0a\x09\x09at: 'printIt' put: [ :cm | cm amberCodeWidget printIt ];\x0a\x09\x09at: 'saveIt' put: [ :cm | cm amberCodeWidget saveIt ];\x0a\x09\x09at: 'browseIt' put: [ :cm | cm amberCodeWidget browseIt ]",
 referencedClasses: [],
 //>>excludeEnd("ide");
-messageSends: ["at:put:", "basicAt:", "codeMirror", "doIt", "amberCodeWidget", "inspectIt", "printIt", "saveIt", "browseIt"]
+messageSends: ["at:put:", "basicAt:", "doIt", "amberCodeWidget", "inspectIt", "printIt", "saveIt", "browseIt"]
 }),
 $globals.HLCodeWidget.a$cls);
 
@@ -1955,7 +1930,7 @@ var self=this,$self=this;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-$self._codeMirror().keyMap["Amber"] = $self._keyMap();
+codeMirrorLib.keyMap["Amber"] = $self._keyMap();
 return self;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx1) {$ctx1.fill(self,"setupKeyMaps",{},$globals.HLCodeWidget.a$cls)});
@@ -1963,7 +1938,7 @@ return self;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "setupKeyMaps\x0a\x09<inlineJS: '$self._codeMirror().keyMap[\x22Amber\x22] = $self._keyMap()'>",
+source: "setupKeyMaps\x0a\x09<inlineJS: 'codeMirrorLib.keyMap[\x22Amber\x22] = $self._keyMap()'>",
 referencedClasses: [],
 //>>excludeEnd("ide");
 messageSends: []

+ 10 - 16
src/Helios-Workspace.st

@@ -235,7 +235,7 @@ saveIt
 !
 
 setEditorOn: aTextarea
-	<inlineJS: '$self["@editor"] = $self._class()._codeMirror().fromTextArea(aTextarea, $self._editorOptions())'>
+	<inlineJS: '$self["@editor"] = codeMirrorLib.fromTextArea(aTextarea, $self._editorOptions())'>
 ! !
 
 !HLCodeWidget methodsFor: 'hints'!
@@ -354,10 +354,6 @@ updateState
 
 !HLCodeWidget class methodsFor: 'accessing'!
 
-codeMirror
-	^ require value: 'codemirror/lib/codemirror'
-!
-
 keyMap
 	^ HLManager current keyBinder systemIsMac
 		ifTrue: [ self macKeyMap ]
@@ -431,12 +427,11 @@ pcKeyMap
 !HLCodeWidget class methodsFor: 'hints'!
 
 hintFor: anEditor options: options
-	| cursor token completions codeMirror |
+	| cursor token completions |
 	
-	codeMirror := self codeMirror.
 	cursor := anEditor getCursor.
 	token := anEditor getTokenAt: cursor.
-	token at: 'state' put: ((codeMirror basicAt: 'innerMode')
+	token at: 'state' put: ((codeMirrorLib basicAt: 'innerMode')
 		value: anEditor getMode value: (token at: 'state')) state.
 	
 	completions := token type = 'variable' 
@@ -445,8 +440,8 @@ hintFor: anEditor options: options
 	
 	^ #{
 		'list' -> completions.
-		'from' -> ((codeMirror basicAt: 'Pos') value: cursor line value: token end).
-		'to' -> ((codeMirror basicAt: 'Pos') value: cursor line value: token start)
+		'from' -> ((codeMirrorLib basicAt: 'Pos') value: cursor line value: token end).
+		'to' -> ((codeMirrorLib basicAt: 'Pos') value: cursor line value: token start)
 	}
 !
 
@@ -472,16 +467,15 @@ initialize
 
 setupCodeMirror
 	<inlineJS: '
-		var codeMirror = $self._codeMirror();
-		codeMirror.keyMap["default"].fallthrough = ["basic"];
-		codeMirror.commands.autocomplete = function(cm) {
-			codeMirror.showHint(cm, $self._hintFor_options_.bind($self));
+		codeMirrorLib.keyMap["default"].fallthrough = ["basic"];
+		codeMirrorLib.commands.autocomplete = function(cm) {
+			codeMirrorLib.showHint(cm, $self._hintFor_options_.bind($self));
 		}
 	'>
 !
 
 setupCommands
-	(self codeMirror basicAt: 'commands') 
+	(codeMirrorLib basicAt: 'commands') 
 		at: 'doIt' put: [ :cm | cm amberCodeWidget doIt ];
 		at: 'inspectIt' put: [ :cm | cm amberCodeWidget inspectIt ];
 		at: 'printIt' put: [ :cm | cm amberCodeWidget printIt ];
@@ -490,7 +484,7 @@ setupCommands
 !
 
 setupKeyMaps
-	<inlineJS: '$self._codeMirror().keyMap["Amber"] = $self._keyMap()'>
+	<inlineJS: 'codeMirrorLib.keyMap["Amber"] = $self._keyMap()'>
 ! !
 
 HLCodeWidget subclass: #HLNavigationCodeWidget