Przeglądaj źródła

Starts to implement theme settings

Benjamin Van Ryseghem 10 lat temu
rodzic
commit
878736ab9a
5 zmienionych plików z 84 dodań i 6 usunięć
  1. 1 1
      css/helios.less
  2. 57 2
      src/Helios-Core.js
  3. 23 0
      src/Helios-Core.st
  4. 2 2
      src/Helios-Workspace.js
  5. 1 1
      src/Helios-Workspace.st

+ 1 - 1
css/helios.less

@@ -46,7 +46,7 @@ body.navigation .CodeMirror pre {
 	}
 }
 
-body[id="helios"] {
+body#helios {
 	font-size: 11px;
 	font-family: "Lucida Grande", "Segoe UI", helvetica, arial, sans-serif;
 	background: #eee url(/images/squared_metal.png) repeat;

+ 57 - 2
src/Helios-Core.js

@@ -3845,6 +3845,44 @@ referencedClasses: ["HLRequestWidget"]
 }),
 globals.HLManager);
 
+smalltalk.addMethod(
+smalltalk.method({
+selector: "setEditorTheme:",
+protocol: 'accessing',
+fn: function (aTheme){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+_st("helios.editorTheme"._asSetting())._value_(aTheme);
+return self}, function($ctx1) {$ctx1.fill(self,"setEditorTheme:",{aTheme:aTheme},globals.HLManager)})},
+args: ["aTheme"],
+source: "setEditorTheme: aTheme\x0a\x0a\x09'helios.editorTheme' asSetting value: aTheme",
+messageSends: ["value:", "asSetting"],
+referencedClasses: []
+}),
+globals.HLManager);
+
+smalltalk.addMethod(
+smalltalk.method({
+selector: "setTheme:",
+protocol: 'accessing',
+fn: function (aTheme){
+var self=this;
+var currentTheme;
+return smalltalk.withContext(function($ctx1) { 
+var $1,$2;
+currentTheme="helios.theme"._asSettingIfAbsent_("default");
+$1="body"._asJQuery();
+_st($1)._removeClass_(_st(currentTheme)._value());
+$2=_st($1)._addClass_(aTheme);
+_st("helios.theme"._asSetting())._value_(aTheme);
+return self}, function($ctx1) {$ctx1.fill(self,"setTheme:",{aTheme:aTheme,currentTheme:currentTheme},globals.HLManager)})},
+args: ["aTheme"],
+source: "setTheme: aTheme\x0a\x09| currentTheme |\x0a\x0a\x09currentTheme := 'helios.theme' asSettingIfAbsent: 'default'.\x0a\x09\x0a\x09'body' asJQuery\x0a\x09\x09removeClass: currentTheme value;\x0a\x09\x09addClass: aTheme.\x0a\x09\x09\x0a\x09\x0a\x09'helios.theme' asSetting value: aTheme",
+messageSends: ["asSettingIfAbsent:", "removeClass:", "asJQuery", "value", "addClass:", "value:", "asSetting"],
+referencedClasses: []
+}),
+globals.HLManager);
+
 smalltalk.addMethod(
 smalltalk.method({
 selector: "setup",
@@ -3859,11 +3897,12 @@ $ctx1.sendIdx["setupEvents"]=1;
 _st(self._keyBinder())._setupEvents();
 $ctx1.sendIdx["setupEvents"]=2;
 _st(self._tabsWidget())._setupEvents();
+self._setupTheme();
 _st("#helper"._asJQuery())._fadeOut();
 return self}, function($ctx1) {$ctx1.fill(self,"setup",{},globals.HLManager)})},
 args: [],
-source: "setup\x0a\x09self \x0a\x09\x09registerServices;\x0a\x09\x09setupEvents.\x0a    self keyBinder setupEvents.\x0a\x09self tabsWidget setupEvents.\x0a\x09\x0a\x09\x0a\x09'#helper' asJQuery fadeOut",
-messageSends: ["registerServices", "setupEvents", "keyBinder", "tabsWidget", "fadeOut", "asJQuery"],
+source: "setup\x0a\x09self \x0a\x09\x09registerServices;\x0a\x09\x09setupEvents.\x0a    self keyBinder setupEvents.\x0a\x09self tabsWidget setupEvents.\x0a\x09self setupTheme.\x0a\x09\x0a\x09\x0a\x09'#helper' asJQuery fadeOut",
+messageSends: ["registerServices", "setupEvents", "keyBinder", "tabsWidget", "setupTheme", "fadeOut", "asJQuery"],
 referencedClasses: []
 }),
 globals.HLManager);
@@ -3907,6 +3946,22 @@ referencedClasses: []
 }),
 globals.HLManager);
 
+smalltalk.addMethod(
+smalltalk.method({
+selector: "setupTheme",
+protocol: 'private',
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+self._setTheme_("niflheim");
+return self}, function($ctx1) {$ctx1.fill(self,"setupTheme",{},globals.HLManager)})},
+args: [],
+source: "setupTheme\x0a\x09self setTheme: 'niflheim'",
+messageSends: ["setTheme:"],
+referencedClasses: []
+}),
+globals.HLManager);
+
 smalltalk.addMethod(
 smalltalk.method({
 selector: "tabWidth",

+ 23 - 0
src/Helios-Core.st

@@ -1199,6 +1199,24 @@ keyBinder
 	^ HLKeyBinder current
 !
 
+setEditorTheme: aTheme
+
+	'helios.editorTheme' asSetting value: aTheme
+!
+
+setTheme: aTheme
+	| currentTheme |
+
+	currentTheme := 'helios.theme' asSettingIfAbsent: 'default'.
+	
+	'body' asJQuery
+		removeClass: currentTheme value;
+		addClass: aTheme.
+		
+	
+	'helios.theme' asSetting value: aTheme
+!
+
 tabWidth
 	^ (window asJQuery width - 90) / self tabs size
 !
@@ -1288,6 +1306,7 @@ setup
 		setupEvents.
     self keyBinder setupEvents.
 	self tabsWidget setupEvents.
+	self setupTheme.
 	
 	
 	'#helper' asJQuery fadeOut
@@ -1317,6 +1336,10 @@ setupEvents
 		
 	window asJQuery resize: [ :event |
 		self refresh ]
+!
+
+setupTheme
+	self setTheme: 'niflheim'
 ! !
 
 !HLManager methodsFor: 'rendering'!

+ 2 - 2
src/Helios-Workspace.js

@@ -455,13 +455,13 @@ var self=this;
 function $HashedCollection(){return globals.HashedCollection||(typeof HashedCollection=="undefined"?nil:HashedCollection)}
 return smalltalk.withContext(function($ctx1) { 
 var $2,$1;
-$2="helios.codeMirrorTheme"._settingValueIfAbsent_("niflheim");
+$2="helios.editorTheme"._settingValueIfAbsent_("default");
 $ctx1.sendIdx["settingValueIfAbsent:"]=1;
 $1=globals.HashedCollection._newFromPairs_(["theme",$2,"mode","text/x-stsrc","lineNumbers",true,"enterMode","flat","indentWithTabs",true,"indentUnit",(4),"matchBrackets",true,"electricChars",false,"keyMap","Amber","extraKeys",_st($HashedCollection())._with_(_st("helios.completionKey"._settingValueIfAbsent_("Shift-Space")).__minus_gt("autocomplete"))]);
 return $1;
 }, function($ctx1) {$ctx1.fill(self,"editorOptions",{},globals.HLCodeWidget)})},
 args: [],
-source: "editorOptions\x0a\x09^ #{\x0a\x09\x09'theme' -> ('helios.codeMirrorTheme' settingValueIfAbsent: 'niflheim').\x0a\x09\x09'mode' -> 'text/x-stsrc'.\x0a        'lineNumbers' -> true.\x0a        'enterMode' -> 'flat'.\x0a        'indentWithTabs' -> true.\x0a\x09\x09'indentUnit' -> 4.\x0a        'matchBrackets' -> true.\x0a        'electricChars' -> false.\x0a\x09\x09'keyMap' -> 'Amber'.\x0a\x09\x09'extraKeys' -> (HashedCollection with: ('helios.completionKey' settingValueIfAbsent: 'Shift-Space') -> 'autocomplete')\x0a\x09}",
+source: "editorOptions\x0a\x09^ #{\x0a\x09\x09'theme' -> ('helios.editorTheme' settingValueIfAbsent: 'default').\x0a\x09\x09'mode' -> 'text/x-stsrc'.\x0a        'lineNumbers' -> true.\x0a        'enterMode' -> 'flat'.\x0a        'indentWithTabs' -> true.\x0a\x09\x09'indentUnit' -> 4.\x0a        'matchBrackets' -> true.\x0a        'electricChars' -> false.\x0a\x09\x09'keyMap' -> 'Amber'.\x0a\x09\x09'extraKeys' -> (HashedCollection with: ('helios.completionKey' settingValueIfAbsent: 'Shift-Space') -> 'autocomplete')\x0a\x09}",
 messageSends: ["settingValueIfAbsent:", "with:", "->"],
 referencedClasses: ["HashedCollection"]
 }),

+ 1 - 1
src/Helios-Workspace.st

@@ -96,7 +96,7 @@ currentLineOrSelection
 
 editorOptions
 	^ #{
-		'theme' -> ('helios.codeMirrorTheme' settingValueIfAbsent: 'niflheim').
+		'theme' -> ('helios.editorTheme' settingValueIfAbsent: 'default').
 		'mode' -> 'text/x-stsrc'.
         'lineNumbers' -> true.
         'enterMode' -> 'flat'.