Commit 11ab86de authored by Gargaj's avatar Gargaj
Browse files

add tab/space options + visible whitespace

parent e95a5474
......@@ -29,6 +29,9 @@ Create a ```config.json``` with e.g. the following contents: (all fields are opt
"outputHeight": 200,
"opacity": 192, // 255 means the editor occludes the effect completely, 0 means the editor is fully transparent
"texturePreviewWidth": 64,
"spacesForTabs": false,
"tabSize": 8,
"visibleWhitespace": true,
},
"midi":{ /* the keys below will become the shader variable names, the values are the CC numbers */
"fMidiKnob": 16, /* e.g. this would be CC#16, i.e. by default the leftmost knob on a nanoKONTROL 2 */
......
......@@ -108,10 +108,17 @@ void ShaderEditor::Initialise()
WndProc(SCI_MARKERSETBACK, markersArray[FOLDER_TYPE][i], 0xFF6A6A6A);
WndProc(SCI_MARKERSETFORE, markersArray[FOLDER_TYPE][i], 0xFF333333);
}
WndProc(SCI_SETUSETABS, 1, NULL);
WndProc(SCI_SETTABWIDTH, 2, NULL);
WndProc(SCI_SETUSETABS, bUseSpacesForTabs ? 0 : 1, NULL);
WndProc(SCI_SETTABWIDTH, nTabSize, NULL);
WndProc(SCI_SETINDENTATIONGUIDES, SC_IV_REAL, NULL);
if (bVisibleWhitespace)
{
WndProc(SCI_SETVIEWWS, SCWS_VISIBLEALWAYS, NULL);
WndProc(SCI_SETWHITESPACEFORE, 1, 0x30FFFFFF);
WndProc(SCI_SETWHITESPACESIZE, 2, NULL );
}
lexState->SetLexer( SCLEX_CPP );
lexState->SetWordList(0, shaderKeyword);
lexState->SetWordList(1, shaderType);
......@@ -126,7 +133,7 @@ void ShaderEditor::Initialise()
SetAStyle(SCE_C_OPERATOR, 0xFF00CCFF, BACKGROUND( 0x000000 ));
SetAStyle(SCE_C_COMMENT, 0xFF00FF00, BACKGROUND( 0x000000 ));
SetAStyle(SCE_C_COMMENTLINE, 0xFF00FF00, BACKGROUND( 0x000000 ));
lexState->Colourise( 0, -1 );
//WndProc( SCI_COLOURISE, NULL, NULL );
......@@ -139,6 +146,10 @@ void ShaderEditor::Initialise( SHADEREDITOR_OPTIONS &options )
nFontSize = options.nFontSize;
sFontFile = options.sFontPath;
nOpacity = options.nOpacity;
bUseSpacesForTabs = options.bUseSpacesForTabs;
nTabSize = options.nTabSize;
bVisibleWhitespace = options.bVisibleWhitespace;
Initialise();
SetPosition( options.rect );
}
......@@ -285,6 +296,7 @@ void ShaderEditor::SetReadOnly( bool b )
WndProc( SCI_SETREADONLY, bReadOnly, NULL );
if (bReadOnly)
{
WndProc(SCI_SETVIEWWS, SCWS_INVISIBLE, NULL);
WndProc(SCI_SETMARGINWIDTHN, 0, 0);
WndProc(SCI_SETMARGINWIDTHN, 1, 0);
WndProc( SCI_SETCARETLINEVISIBLE, 0, NULL);
......
......@@ -53,6 +53,9 @@ struct SHADEREDITOR_OPTIONS {
int nFontSize;
Scintilla::PRectangle rect;
unsigned char nOpacity;
bool bUseSpacesForTabs;
int nTabSize;
bool bVisibleWhitespace;
};
class ShaderEditor : public Scintilla::Editor
......@@ -60,10 +63,15 @@ class ShaderEditor : public Scintilla::Editor
Scintilla::Surface *surfaceWindow;
Scintilla::LexState * lexState;
bool bReadOnly;
bool bHasMouseCapture;
std::string sFontFile;
int nFontSize;
bool bHasMouseCapture;
unsigned char nOpacity;
bool bUseSpacesForTabs;
int nTabSize;
bool bVisibleWhitespace;
public:
ShaderEditor(Scintilla::Surface *surfaceWindow);
......
......@@ -67,17 +67,22 @@ int main()
std::map<std::string,Renderer::Texture*> textures;
std::map<int,std::string> midiRoutes;
int nFontSize = 16;
SHADEREDITOR_OPTIONS options;
options.nFontSize = 16;
#ifdef _WIN32
std::string sFontPath = "c:\\Windows\\Fonts\\cour.ttf";
options.sFontPath = "c:\\Windows\\Fonts\\cour.ttf";
#else
std::string sFontPath = "/usr/share/fonts/corefonts/cour.ttf";
options.sFontPath = "/usr/share/fonts/corefonts/cour.ttf";
#endif
unsigned char nOpacity = 0xC0;
options.nOpacity = 0xC0;
options.bUseSpacesForTabs = true;
options.nTabSize = 2;
options.bVisibleWhitespace = false;
int nDebugOutputHeight = 200;
int nTexPreviewWidth = 64;
char szConfig[65535];
FILE * fConf = fopen("config.json","rb");
if (fConf)
......@@ -104,9 +109,9 @@ int main()
if (o.has<jsonxx::Object>("font"))
{
if (o.get<jsonxx::Object>("font").has<jsonxx::Number>("size"))
nFontSize = o.get<jsonxx::Object>("font").get<jsonxx::Number>("size");
options.nFontSize = o.get<jsonxx::Object>("font").get<jsonxx::Number>("size");
if (o.get<jsonxx::Object>("font").has<jsonxx::String>("file"))
sFontPath = o.get<jsonxx::Object>("font").get<jsonxx::String>("file");
options.sFontPath = o.get<jsonxx::Object>("font").get<jsonxx::String>("file");
}
if (o.has<jsonxx::Object>("gui"))
{
......@@ -115,7 +120,13 @@ int main()
if (o.get<jsonxx::Object>("gui").has<jsonxx::Number>("texturePreviewWidth"))
nTexPreviewWidth = o.get<jsonxx::Object>("gui").get<jsonxx::Number>("texturePreviewWidth");
if (o.get<jsonxx::Object>("gui").has<jsonxx::Number>("opacity"))
nOpacity = o.get<jsonxx::Object>("gui").get<jsonxx::Number>("opacity");
options.nOpacity = o.get<jsonxx::Object>("gui").get<jsonxx::Number>("opacity");
if (o.get<jsonxx::Object>("gui").has<jsonxx::Boolean>("spacesForTabs"))
options.bUseSpacesForTabs = o.get<jsonxx::Object>("gui").get<jsonxx::Boolean>("spacesForTabs");
if (o.get<jsonxx::Object>("gui").has<jsonxx::Number>("tabSize"))
options.nTabSize = o.get<jsonxx::Object>("gui").get<jsonxx::Number>("tabSize");
if (o.get<jsonxx::Object>("gui").has<jsonxx::Boolean>("visibleWhitespace"))
options.bVisibleWhitespace = o.get<jsonxx::Object>("gui").get<jsonxx::Boolean>("visibleWhitespace");
}
if (o.has<jsonxx::Object>("midi"))
{
......@@ -175,10 +186,6 @@ int main()
bool bTexPreviewVisible = true;
SHADEREDITOR_OPTIONS options;
options.sFontPath = sFontPath;
options.nFontSize = nFontSize;
options.nOpacity = nOpacity;
options.rect = Scintilla::PRectangle( nMargin, nMargin, settings.nWidth - nMargin - nTexPreviewWidth - nMargin, settings.nHeight - nMargin * 2 - nDebugOutputHeight );
ShaderEditor mShaderEditor( surface );
mShaderEditor.Initialise( options );
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment