Pārlūkot izejas kodu

Syntax hilighting theme support and Solarized Dark theme for IDE

Ivan Safrin 13 gadi atpakaļ
vecāks
revīzija
0f8b40abc1

+ 1 - 0
Core/Contents/Include/PolyLabel.h

@@ -93,6 +93,7 @@ namespace Polycode {
 					
 					
 			static const int ANTIALIAS_FULL = 0;
 			static const int ANTIALIAS_FULL = 0;
 			static const int ANTIALIAS_NONE = 1;
 			static const int ANTIALIAS_NONE = 1;
+			static const int ANTIALIAS_STRONG = 2;			
 			
 			
 			int getBaselineAdjust();
 			int getBaselineAdjust();
 			
 			

+ 9 - 2
Core/Contents/Source/PolyLabel.cpp

@@ -258,6 +258,7 @@ void Label::precacheGlyphs(String text, GlyphData *glyphData) {
 
 
 		switch(antiAliasMode) {
 		switch(antiAliasMode) {
 			case ANTIALIAS_FULL:
 			case ANTIALIAS_FULL:
+			case ANTIALIAS_STRONG:
 				error = FT_Load_Glyph( face, glyph_index, FT_LOAD_TARGET_LIGHT);			
 				error = FT_Load_Glyph( face, glyph_index, FT_LOAD_TARGET_LIGHT);			
 			break;
 			break;
 			default:
 			default:
@@ -293,14 +294,20 @@ void Label::drawGlyphBitmap(FT_Bitmap *bitmap, unsigned int x, unsigned int y, C
 
 
 	int lineoffset = (height-y) * (width*4);
 	int lineoffset = (height-y) * (width*4);
 	int xoff = (x*4);
 	int xoff = (x*4);
+	
+	Number alphaMultiplier = 1.0;
+	if(antiAliasMode == ANTIALIAS_STRONG) {
+		alphaMultiplier = 1.5;
+	}
 
 
 	switch(antiAliasMode) {
 	switch(antiAliasMode) {
 			case ANTIALIAS_FULL:
 			case ANTIALIAS_FULL:
+			case ANTIALIAS_STRONG:			
 				for(int j = 0; j < ((bitmap->width * bitmap->rows)); j++) {
 				for(int j = 0; j < ((bitmap->width * bitmap->rows)); j++) {
 					if(!(j % bitmap->width) && j !=0)
 					if(!(j % bitmap->width) && j !=0)
 						lineoffset -= ((width*4)+(bitmap->width * 4));
 						lineoffset -= ((width*4)+(bitmap->width * 4));
 						
 						
-						int newVal = imageData[xoff+lineoffset+3] + bitmap->buffer[j];
+						int newVal = imageData[xoff+lineoffset+3] + (bitmap->buffer[j] * alphaMultiplier);
 						if(newVal > 255)
 						if(newVal > 255)
 							newVal = 255;
 							newVal = 255;
 
 
@@ -365,7 +372,7 @@ void Label::renderGlyphs(GlyphData *glyphData) {
 		pen.x = (start_x + glyphData->positions[n].x) * 64;
 		pen.x = (start_x + glyphData->positions[n].x) * 64;
 		pen.y = (start_y + glyphData->positions[n].y) * 64;		
 		pen.y = (start_y + glyphData->positions[n].y) * 64;		
 
 
-		if(antiAliasMode == ANTIALIAS_FULL) {
+		if(antiAliasMode == ANTIALIAS_FULL || antiAliasMode == ANTIALIAS_STRONG) {
 			error = FT_Glyph_To_Bitmap( &image, FT_RENDER_MODE_LIGHT, &pen, 0 );		
 			error = FT_Glyph_To_Bitmap( &image, FT_RENDER_MODE_LIGHT, &pen, 0 );		
 		} else {
 		} else {
 			error = FT_Glyph_To_Bitmap( &image, FT_RENDER_MODE_MONO, &pen, 0 );				
 			error = FT_Glyph_To_Bitmap( &image, FT_RENDER_MODE_MONO, &pen, 0 );				

+ 2 - 1
IDE/Contents/Include/PolycodeGlobals.h

@@ -22,4 +22,5 @@
  
  
 #pragma once
 #pragma once
 
 
-#define RESOURCE_PATH ""
+#define RESOURCE_PATH ""
+

+ 12 - 4
IDE/Contents/Include/PolycodeTextEditor.h

@@ -28,6 +28,17 @@
 
 
 using namespace Polycode;
 using namespace Polycode;
 
 
+class SyntaxHighlightTheme {
+	public:
+		void loadFromFile(String themeName);		
+		String name;
+		Color bgColor;
+		Color selectionColor;
+		Color cursorColor;
+		bool useStrongHinting;
+		Color colors[8];
+};
+
 class FindBar : public UIElement {
 class FindBar : public UIElement {
 	public:
 	public:
 		FindBar();
 		FindBar();
@@ -55,10 +66,7 @@ class PolycodeSyntaxHighlighter : public UITextInputSyntaxHighlighter {
 		bool contains(String part, std::vector<String> list);
 		bool contains(String part, std::vector<String> list);
 	
 	
 		std::vector<SyntaxHighlightToken> parseText(String text);		
 		std::vector<SyntaxHighlightToken> parseText(String text);		
-		std::vector<SyntaxHighlightToken> parseLua(String text);
-		
-		Color colorScheme[16];
-				
+		std::vector<SyntaxHighlightToken> parseLua(String text);	
 		
 		
 	protected:
 	protected:
 	
 	

+ 16 - 0
IDE/Contents/Resources/SyntaxThemes/default.xml

@@ -0,0 +1,16 @@
+<?xml version="1.0" ?>
+<syntaxTheme useStrongHinting="false">
+	<bgColor r="255" g="255" b="255"/>
+	<cursorColor r="0" g="0" b="0"/>
+	<selectionColor r="182" g="212" b="255"/>		
+	<textColors>
+		<color r="0" g="0" b="0"/>
+		<color r="0" g="112" b="0"/>
+		<color r="192" g="45" b="167"/>
+		<color r="48" g="99" b="105"/>
+		<color r="227" g="11" b="0"/>
+		<color r="82" g="31" b="140"/>
+		<color r="39" g="41" b="215"/>
+		<color r="0" g="0" b="0"/>		
+	</textColors>
+</syntaxTheme>

+ 16 - 0
IDE/Contents/Resources/SyntaxThemes/solarized_dark.xml

@@ -0,0 +1,16 @@
+<?xml version="1.0" ?>
+<syntaxTheme useStrongHinting="true">
+	<bgColor r="5" g="32" b="42"/>
+	<cursorColor r="130" g="144" b="144"/>
+	<selectionColor r="88" g="110" b="117"/>
+	<textColors>
+		<color r="113" g="130" b="132"/>
+		<color r="71" g="91" b="98"/>
+		<color r="193" g="33" b="114"/>
+		<color r="46" g="145" b="134"/>
+		<color r="204" g="33" b="30"/>
+		<color r="118" g="137" b="0"/>
+		<color r="86" g="90" b="190"/>
+		<color r="0" g="0" b="0"/>		
+	</textColors>
+</syntaxTheme>

+ 3 - 3
IDE/Contents/Resources/UIThemes/default/theme.xml

@@ -2,10 +2,10 @@
 <PolyConfig>
 <PolyConfig>
 	<uiDefaultFontName>sans</uiDefaultFontName>
 	<uiDefaultFontName>sans</uiDefaultFontName>
 	<uiTextInputFontName>sans</uiTextInputFontName>
 	<uiTextInputFontName>sans</uiTextInputFontName>
-	<uiTextInputFontNameMultiLine>mono</uiTextInputFontNameMultiLine>
+	<uiTextInputFontNameMultiLine>editor_font</uiTextInputFontNameMultiLine>
 	<uiDefaultFontSize>11</uiDefaultFontSize>
 	<uiDefaultFontSize>11</uiDefaultFontSize>
 	<uiTextInputFontSize>11</uiTextInputFontSize>
 	<uiTextInputFontSize>11</uiTextInputFontSize>
-	<uiTextInputFontSizeMultiline>12</uiTextInputFontSizeMultiline>	
+	<uiTextInputFontSizeMultiline>11</uiTextInputFontSizeMultiline>	
 	<uiTreeArrowIconImage>arrowIcon.png</uiTreeArrowIconImage>
 	<uiTreeArrowIconImage>arrowIcon.png</uiTreeArrowIconImage>
 	<uiTreeCellHeight>20</uiTreeCellHeight>
 	<uiTreeCellHeight>20</uiTreeCellHeight>
 	<uiTreeCellPadding>4</uiTreeCellPadding>
 	<uiTreeCellPadding>4</uiTreeCellPadding>
@@ -77,7 +77,7 @@
 	<textBgSkinB>3</textBgSkinB>
 	<textBgSkinB>3</textBgSkinB>
 	<textBgSkinL>3</textBgSkinL>
 	<textBgSkinL>3</textBgSkinL>
 	<textBgSkinPadding>5</textBgSkinPadding>
 	<textBgSkinPadding>5</textBgSkinPadding>
-	<textEditLineSpacing>16</textEditLineSpacing>
+	<textEditLineSpacing>12</textEditLineSpacing>
 		
 		
 	<uiScrollHandleMinSize>30</uiScrollHandleMinSize>	
 	<uiScrollHandleMinSize>30</uiScrollHandleMinSize>	
 	<uiTreeContainerScrollBarOffset>27</uiTreeContainerScrollBarOffset>
 	<uiTreeContainerScrollBarOffset>27</uiTreeContainerScrollBarOffset>

+ 1 - 1
IDE/Contents/Source/PolycodeFrame.cpp

@@ -256,7 +256,7 @@ void EditCurve::updatePoints() {
 		if(i == targetCurve->getNumControlPoints()-1)
 		if(i == targetCurve->getNumControlPoints()-1)
 			type = EditPoint::TYPE_END_POINT;
 			type = EditPoint::TYPE_END_POINT;
 
 
-	
+
 		EditPoint *point = new EditPoint(targetCurve->getControlPoint(i), type);
 		EditPoint *point = new EditPoint(targetCurve->getControlPoint(i), type);
 		point->setMode(mode);
 		point->setMode(mode);
 		point->addEventListener(this, Event::CHANGE_EVENT);
 		point->addEventListener(this, Event::CHANGE_EVENT);

+ 21 - 6
IDE/Contents/Source/PolycodeIDEApp.cpp

@@ -26,6 +26,7 @@
 using namespace Polycode;
 using namespace Polycode;
 
 
 UIGlobalMenu *globalMenu;
 UIGlobalMenu *globalMenu;
+SyntaxHighlightTheme *globalSyntaxTheme;
 
 
 PolycodeIDEApp::PolycodeIDEApp(PolycodeView *view) : EventDispatcher() {
 PolycodeIDEApp::PolycodeIDEApp(PolycodeView *view) : EventDispatcher() {
 	core = new CocoaCore(view, 900,700,false,true, 0, 0,30);	
 	core = new CocoaCore(view, 900,700,false,true, 0, 0,30);	
@@ -43,11 +44,14 @@ PolycodeIDEApp::PolycodeIDEApp(PolycodeView *view) : EventDispatcher() {
 
 
 	CoreServices::getInstance()->getResourceManager()->addArchive("api.pak");
 	CoreServices::getInstance()->getResourceManager()->addArchive("api.pak");
 
 
-	CoreServices::getInstance()->getConfig()->loadConfig("Polycode", RESOURCE_PATH"UIThemes/default/theme.xml");
-	CoreServices::getInstance()->getResourceManager()->addArchive(RESOURCE_PATH"UIThemes/default/");
-	CoreServices::getInstance()->getResourceManager()->addArchive(RESOURCE_PATH"Images/");	
+	CoreServices::getInstance()->getConfig()->loadConfig("Polycode", "UIThemes/default/theme.xml");
+	CoreServices::getInstance()->getResourceManager()->addArchive("UIThemes/default/");
+	CoreServices::getInstance()->getResourceManager()->addArchive("Images/");	
+
+	CoreServices::getInstance()->getFontManager()->registerFont("section", "Fonts/LeagueGothic-Regular.otf");	
+
+	CoreServices::getInstance()->getFontManager()->registerFont("editor_font", "/Library/Fonts/Menlo.ttc");
 
 
-	CoreServices::getInstance()->getFontManager()->registerFont("section", "Fonts/LeagueGothic-Regular.otf");
 	
 	
 //	CoreServices::getInstance()->getRenderer()->setTextureFilteringMode(Renderer::TEX_FILTERING_LINEAR);
 //	CoreServices::getInstance()->getRenderer()->setTextureFilteringMode(Renderer::TEX_FILTERING_LINEAR);
 	CoreServices::getInstance()->getRenderer()->setTextureFilteringMode(Renderer::TEX_FILTERING_NEAREST);
 	CoreServices::getInstance()->getRenderer()->setTextureFilteringMode(Renderer::TEX_FILTERING_NEAREST);
@@ -476,6 +480,7 @@ void PolycodeIDEApp::saveConfigFile() {
 	Object configFile;
 	Object configFile;
 	configFile.root.name = "config";
 	configFile.root.name = "config";
 	configFile.root.addChild("open_projects");
 	configFile.root.addChild("open_projects");
+	configFile.root.addChild("syntax_theme", globalSyntaxTheme->name);
 	for(int i=0; i < projectManager->getProjectCount(); i++) {
 	for(int i=0; i < projectManager->getProjectCount(); i++) {
 		PolycodeProject *project = projectManager->getProjectByIndex(i);		
 		PolycodeProject *project = projectManager->getProjectByIndex(i);		
 		ObjectEntry *projectEntry = configFile.root["open_projects"]->addChild("project");
 		ObjectEntry *projectEntry = configFile.root["open_projects"]->addChild("project");
@@ -487,9 +492,19 @@ void PolycodeIDEApp::saveConfigFile() {
 }
 }
 
 
 void PolycodeIDEApp::loadConfigFile() {
 void PolycodeIDEApp::loadConfigFile() {
-
 	Object configFile;
 	Object configFile;
-	configFile.loadFromXML(core->getUserHomeDirectory()+"/Library/Application Support/Polycode/config.xml");		
+	// TODO: Make a crossplatform core method to get application data path
+	configFile.loadFromXML(core->getUserHomeDirectory()+"/Library/Application Support/Polycode/config.xml");
+		
+	globalSyntaxTheme = new SyntaxHighlightTheme();
+	String themeName = "default";
+	ObjectEntry *syntaxTheme = configFile.root["syntax_theme"];
+	if(syntaxTheme) {
+		themeName = syntaxTheme->stringVal;
+	}
+	themeName = "solarized_dark";	
+	globalSyntaxTheme->loadFromFile(themeName);
+	
 	if(configFile.root["open_projects"]) {
 	if(configFile.root["open_projects"]) {
 		ObjectEntry *projects = configFile.root["open_projects"];
 		ObjectEntry *projects = configFile.root["open_projects"];
 		if(projects) {
 		if(projects) {

+ 74 - 17
IDE/Contents/Source/PolycodeTextEditor.cpp

@@ -22,15 +22,69 @@
 
 
 #include "PolycodeTextEditor.h"
 #include "PolycodeTextEditor.h"
 
 
-PolycodeSyntaxHighlighter::PolycodeSyntaxHighlighter(String extension) {
+extern SyntaxHighlightTheme *globalSyntaxTheme;
+
+void SyntaxHighlightTheme::loadFromFile(String themeName) {
+	String filePath = "SyntaxThemes/"+themeName+".xml";
+	
+	this->name =themeName;
+	
+	Object themeObject;
+	if(themeObject.loadFromXML(filePath)) {
+
+		ObjectEntry *hintingEntry = themeObject.root["useStrongHinting"];
+		if(hintingEntry) {
+			useStrongHinting = hintingEntry->boolVal;
+		}
+	
+		ObjectEntry *bgColorEntry = themeObject.root["bgColor"];		
+		if(bgColorEntry) {
+			ObjectEntry *r = (*bgColorEntry)["r"];
+			ObjectEntry *g = (*bgColorEntry)["g"];
+			ObjectEntry *b = (*bgColorEntry)["b"];
+			if(r && g && b) {
+				bgColor.setColorRGB(r->intVal, g->intVal, b->intVal);
+			}		
+		}
+
+		ObjectEntry *cursorColorEntry = themeObject.root["cursorColor"];		
+		if(cursorColorEntry) {
+			ObjectEntry *r = (*cursorColorEntry)["r"];
+			ObjectEntry *g = (*cursorColorEntry)["g"];
+			ObjectEntry *b = (*cursorColorEntry)["b"];
+			if(r && g && b) {
+				cursorColor.setColorRGB(r->intVal, g->intVal, b->intVal);
+			}		
+		}
 
 
-	colorScheme[0] = Color(0.0, 0.0, 0.0, 1.0);
-	colorScheme[1] = Color(0.0/255.0, 112.0/255.0, 0.0, 1.0);
-	colorScheme[2] = Color(192.0/255.0, 45.0/255.0, 167.0/255.0, 1.0);
-	colorScheme[3] = Color(48.0/255.0, 99.0/255.0, 105.0/255.0, 1.0);
-	colorScheme[4] = Color(227.0/255.0, 11.0/255.0, 0.0/255.0, 1.0);
-	colorScheme[5] = Color(82.0/255.0, 31.0/255.0, 140.0/255.0, 1.0);	
-	colorScheme[6] = Color(39.0/255.0, 41.0/255.0, 215.0/255.0, 1.0);
+		ObjectEntry *selectionColorEntry = themeObject.root["selectionColor"];		
+		if(selectionColorEntry) {
+			ObjectEntry *r = (*selectionColorEntry)["r"];
+			ObjectEntry *g = (*selectionColorEntry)["g"];
+			ObjectEntry *b = (*selectionColorEntry)["b"];
+			if(r && g && b) {
+				selectionColor.setColorRGB(r->intVal, g->intVal, b->intVal);
+			}		
+		}
+			
+		ObjectEntry *textColors = themeObject.root["textColors"];
+		if(textColors) {
+			for(int i=0; i < textColors->length && i < 8; i++) {
+				ObjectEntry *colorEntry = (*textColors)[i];
+				if(colorEntry) {
+					ObjectEntry *r = (*colorEntry)["r"];
+					ObjectEntry *g = (*colorEntry)["g"];
+					ObjectEntry *b = (*colorEntry)["b"];
+					if(r && g && b) {
+						colors[i].setColorRGB(r->intVal, g->intVal, b->intVal);
+					}
+				}				
+			}
+		}
+	}
+}
+
+PolycodeSyntaxHighlighter::PolycodeSyntaxHighlighter(String extension) {
 	
 	
 //	String separators = " ;()\t\n=+-/\\'\"";	
 //	String separators = " ;()\t\n=+-/\\'\"";	
 //	String keywords = "true,false,";
 //	String keywords = "true,false,";
@@ -170,28 +224,27 @@ std::vector<SyntaxHighlightToken> PolycodeSyntaxHighlighter::parseLua(String tex
 	for(int i=0; i < tokens.size(); i++) {
 	for(int i=0; i < tokens.size(); i++) {
 		switch(tokens[i].type) {
 		switch(tokens[i].type) {
 			case MODE_STRING:
 			case MODE_STRING:
-				tokens[i].color = colorScheme[4];			
+				tokens[i].color = globalSyntaxTheme->colors[4];			
 			break;
 			break;
 			case MODE_COMMENT:
 			case MODE_COMMENT:
-				tokens[i].color = colorScheme[1];			
+				tokens[i].color = globalSyntaxTheme->colors[1];			
 			break;			
 			break;			
 			case MODE_METHOD:
 			case MODE_METHOD:
-				tokens[i].color = colorScheme[3];			
+				tokens[i].color = globalSyntaxTheme->colors[3];			
 			break;			
 			break;			
 			case MODE_KEYWORD:
 			case MODE_KEYWORD:
-				tokens[i].color = colorScheme[2];
+				tokens[i].color = globalSyntaxTheme->colors[2];
 			break;		
 			break;		
 			case MODE_NUMBER:
 			case MODE_NUMBER:
-				tokens[i].color = colorScheme[6];
+				tokens[i].color = globalSyntaxTheme->colors[6];
 			break;		
 			break;		
 			case MODE_MEMBER:
 			case MODE_MEMBER:
-				tokens[i].color = colorScheme[5];
+				tokens[i].color = globalSyntaxTheme->colors[5];
 			break;															
 			break;															
 			default:
 			default:
-				tokens[i].color = colorScheme[0];
+				tokens[i].color = globalSyntaxTheme->colors[0];
 			break;
 			break;
 		}
 		}
-//		printf("%s(%d)", tokens[i].text.c_str(), tokens[i].type);		
 	}
 	}
 	
 	
 	return tokens;
 	return tokens;
@@ -209,7 +262,11 @@ PolycodeTextEditor::~PolycodeTextEditor() {
 bool PolycodeTextEditor::openFile(OSFileEntry filePath) {
 bool PolycodeTextEditor::openFile(OSFileEntry filePath) {
 	
 	
 	textInput = new UITextInput(true, 100, 100);
 	textInput = new UITextInput(true, 100, 100);
-	addChild(textInput);	
+	addChild(textInput);
+	textInput->setBackgroundColor(globalSyntaxTheme->bgColor);
+	textInput->setCursorColor(globalSyntaxTheme->cursorColor);
+	textInput->setSelectionColor(globalSyntaxTheme->selectionColor);
+	textInput->useStrongHinting = globalSyntaxTheme->useStrongHinting;
 	
 	
 	findBar = new FindBar();
 	findBar = new FindBar();
 	findBar->visible = false;
 	findBar->visible = false;

+ 7 - 0
Modules/Contents/UI/Include/PolyUITextInput.h

@@ -102,6 +102,10 @@ namespace Polycode {
 			void Copy();
 			void Copy();
 			void Paste();
 			void Paste();
 			
 			
+			void setBackgroundColor(Color color);
+			void setSelectionColor(Color color);
+			void setCursorColor(Color color);
+						
 			void replaceAll(String what, String withWhat);
 			void replaceAll(String what, String withWhat);
 			
 			
 			void findString(String stringToFind, bool replace=false, String replaceString="");
 			void findString(String stringToFind, bool replace=false, String replaceString="");
@@ -113,6 +117,7 @@ namespace Polycode {
 
 
 			void setSyntaxHighlighter(UITextInputSyntaxHighlighter *syntaxHighliter);
 			void setSyntaxHighlighter(UITextInputSyntaxHighlighter *syntaxHighliter);
 					
 					
+			bool isNumberOrCharacter(wchar_t charCode);
 			void Resize(Number width, Number height);
 			void Resize(Number width, Number height);
 			
 			
 			void setNumberOnly(bool val);
 			void setNumberOnly(bool val);
@@ -123,6 +128,8 @@ namespace Polycode {
 			void insertText(String text);
 			void insertText(String text);
 			
 			
 			UIScrollContainer *getScrollContainer();
 			UIScrollContainer *getScrollContainer();
+			
+			bool useStrongHinting;
 		
 		
 		protected:
 		protected:
 				
 				

+ 43 - 8
Modules/Contents/UI/Source/PolyUITextInput.cpp

@@ -35,6 +35,8 @@ UITextInput::UITextInput(bool multiLine, Number width, Number height) : UIElemen
 	processInputEvents = true;
 	processInputEvents = true;
 	isNumberOnly = false;
 	isNumberOnly = false;
 	
 	
+	useStrongHinting = false;
+	
 	draggingSelection = false;
 	draggingSelection = false;
 	hasSelection = false;
 	hasSelection = false;
 	doSelectToCaret = false;
 	doSelectToCaret = false;
@@ -405,7 +407,12 @@ int UITextInput::insertLine(bool after) {
 	
 	
 	numLines++;	
 	numLines++;	
 	
 	
-	ScreenLabel *newLine = new ScreenLabel(L"", fontSize, fontName, Label::ANTIALIAS_FULL);
+	int aaMode = Label::ANTIALIAS_FULL;
+	if(useStrongHinting) {
+		aaMode = Label::ANTIALIAS_STRONG;
+	}
+
+	ScreenLabel *newLine = new ScreenLabel(L"", fontSize, fontName, aaMode);
 	newLine->setColor(0,0,0,1);
 	newLine->setColor(0,0,0,1);
 	lineHeight = newLine->getHeight();
 	lineHeight = newLine->getHeight();
 	linesContainer->addChild(newLine);
 	linesContainer->addChild(newLine);
@@ -574,7 +581,7 @@ int UITextInput::caretSkipWordBack(int caretLine, int caretPosition) {
 	for(int i=caretPosition; i > 0; i--) {
 	for(int i=caretPosition; i > 0; i--) {
 		String bit = lines[caretLine]->getText().substr(i,1);
 		String bit = lines[caretLine]->getText().substr(i,1);
 		char chr = ((char*)bit.c_str())[0]; 		
 		char chr = ((char*)bit.c_str())[0]; 		
-		if(((chr > 0 && chr < 48) || (chr > 57 && chr < 65) || (chr > 90 && chr < 97) || (chr > 122 && chr < 127)) && i < caretPosition-1) {
+		if(!isNumberOrCharacter(chr) && i < caretPosition-1) {
 			return i+1;
 			return i+1;
 		}
 		}
 	}	
 	}	
@@ -586,7 +593,7 @@ int UITextInput::caretSkipWordForward(int caretLine, int caretPosition) {
 	for(int i=caretPosition; i < len; i++) {
 	for(int i=caretPosition; i < len; i++) {
 		String bit = lines[caretLine]->getText().substr(i,1);
 		String bit = lines[caretLine]->getText().substr(i,1);
 		char chr = ((char*)bit.c_str())[0]; 
 		char chr = ((char*)bit.c_str())[0]; 
-		if(((chr > 0 && chr < 48) || (chr > 57 && chr < 65) || (chr > 90 && chr < 97) || (chr > 122 && chr < 127)) && i > caretPosition) {
+		if(!isNumberOrCharacter(chr) && i > caretPosition) {
 			return i;
 			return i;
 		}
 		}
 	}
 	}
@@ -826,6 +833,20 @@ String UITextInput::getSelectionText() {
 	return totalText;
 	return totalText;
 }
 }
 
 
+void UITextInput::setSelectionColor(Color color) {
+	selectorRectTop->color = color;
+	selectorRectMiddle->color = color;
+	selectorRectBottom->color = color;
+}
+
+void UITextInput::setCursorColor(Color color) {
+	blinkerRect->color = color;
+}
+
+void UITextInput::setBackgroundColor(Color color) {
+	inputRect->color = color;
+}
+
 UIScrollContainer *UITextInput::getScrollContainer() {
 UIScrollContainer *UITextInput::getScrollContainer() {
 	return scrollContainer;
 	return scrollContainer;
 }
 }
@@ -908,6 +929,20 @@ void UITextInput::showLine(unsigned int lineNumber, bool top) {
 	}
 	}
 }
 }
 
 
+bool UITextInput::isNumberOrCharacter(wchar_t charCode) {
+	if(charCode > 47 && charCode < 58)
+		return true;
+
+	if(charCode > 64 && charCode < 91)
+		return true;
+
+	if(charCode > 96 && charCode < 123)
+		return true;
+
+
+	return false;
+}
+
 void UITextInput::onKeyDown(PolyKEY key, wchar_t charCode) {
 void UITextInput::onKeyDown(PolyKEY key, wchar_t charCode) {
 	
 	
 	if(!hasFocus)
 	if(!hasFocus)
@@ -1123,12 +1158,12 @@ void UITextInput::onKeyDown(PolyKEY key, wchar_t charCode) {
 	}	
 	}	
 	
 	
 	String ctext = currentLine->getText();
 	String ctext = currentLine->getText();
-	
-	
-//	if(1) {
+		
 	if((charCode > 31 && charCode < 127) || charCode > 127) {	
 	if((charCode > 31 && charCode < 127) || charCode > 127) {	
 		if(!isNumberOnly || (isNumberOnly && ((charCode > 47 && charCode < 58) || (charCode == '.' || charCode == '-')))) {
 		if(!isNumberOnly || (isNumberOnly && ((charCode > 47 && charCode < 58) || (charCode == '.' || charCode == '-')))) {
-			saveUndoState();
+			if(!isNumberOrCharacter(charCode)) { 
+				saveUndoState();
+			}
 			if(hasSelection)
 			if(hasSelection)
 				deleteSelection();
 				deleteSelection();
 			ctext = currentLine->getText();		
 			ctext = currentLine->getText();		
@@ -1196,7 +1231,7 @@ void UITextInput::Update() {
 	if(hasSelection) {
 	if(hasSelection) {
 		blinkerRect->visible = false;
 		blinkerRect->visible = false;
 	}
 	}
-	blinkerRect->setPosition(caretImagePosition,currentLine->getPosition2D().y - 2);
+	blinkerRect->setPosition(caretImagePosition,currentLine->getPosition2D().y);
 	if(hasFocus) {
 	if(hasFocus) {
 //		inputRect->setStrokeColor(1.0f, 1.0f, 1.0f, 0.25f);	
 //		inputRect->setStrokeColor(1.0f, 1.0f, 1.0f, 0.25f);	
 	} else {
 	} else {