@@ -31,25 +31,25 @@ int g_themeId = 0;
3131const int theme1[] = {
3232 0xc8cedb , 0xa7aebc , 0x484f5f , 0xa7aebc , 0xa7aebc , 0x00bb00 ,
3333 0x272b33 , 0x3d4350 , 0x2b3039 , 0x3875ed , 0x373b88 , 0x2b313a ,
34- 0x0083f8 , 0xff9d00 , 0x31ccac , 0xc679dd
34+ 0x0083f8 , 0xff9d00 , 0x31ccac , 0xc679dd , 0x0083f8
3535};
3636
3737const int theme2[] = {
3838 0xc8cedb , 0x002b36 , 0x3d4350 , 0xa7aebc , 0xa7aebc , 0x00bb00 ,
3939 0x002b36 , 0x657b83 , 0x073642 , 0x9f7d18 , 0x2b313a , 0x073642 ,
40- 0x0083f8 , 0xff9d00 , 0x31ccac , 0xc679dd
40+ 0x0083f8 , 0xff9d00 , 0x31ccac , 0xc679dd , 0x0083f8
4141};
4242
4343const int theme3[] = {
4444 0xc8cedb , 0xd7decc , 0x484f5f , 0xa7aebc , 0xa7aebc , 0x00bb00 ,
4545 0x001b33 , 0x0088ff , 0x000d1a , 0x0051b1 , 0x373b88 , 0x022444 ,
46- 0x0083f8 , 0xff9d00 , 0x31ccac , 0xc679dd
46+ 0x0083f8 , 0xff9d00 , 0x31ccac , 0xc679dd , 0x0083f8
4747};
4848
4949const int theme4[] = {
5050 0xc8cedb , 0xa7aebc , 0x484f5f , 0xa7aebc , 0xa7aebc , 0x00bb00 ,
5151 0x2e3436 , 0x888a85 , 0x000000 , 0x4d483b , 0x000000 , 0x2b313a ,
52- 0x0083f8 , 0xff9d00 , 0x31ccac , 0xc679dd
52+ 0x0083f8 , 0xff9d00 , 0x31ccac , 0xc679dd , 0x0083f8
5353};
5454
5555const int * themes[] = {
@@ -81,6 +81,7 @@ const char *helpText =
8181 " SHIFT-<arrow> select\n "
8282 " TAB indent line\n "
8383 " F1,A-h keyword help\n "
84+ " F4 toggle marker\n "
8485 " F5 debug\n "
8586 " F9, C-r run\n " ;
8687
@@ -119,7 +120,8 @@ EditTheme::EditTheme(int fg, int bg) :
119120 _syntax_text(fg),
120121 _syntax_command(fg),
121122 _syntax_statement(fg),
122- _syntax_digit(fg) {
123+ _syntax_digit(fg),
124+ _row_marker(fg) {
123125}
124126
125127void EditTheme::selectTheme (const int theme[]) {
@@ -139,6 +141,7 @@ void EditTheme::selectTheme(const int theme[]) {
139141 _syntax_command = theme[13 ];
140142 _syntax_statement = theme[14 ];
141143 _syntax_digit = theme[15 ];
144+ _row_marker = theme[16 ];
142145}
143146
144147//
@@ -255,6 +258,7 @@ TextEditInput::TextEditInput(const char *text, int chW, int chH,
255258 _matchingBrace(-1 ),
256259 _dirty(false ) {
257260 stb_textedit_initialize_state (&_state, false );
261+ memset (_lineMarker, -1 , sizeof (_lineMarker));
258262}
259263
260264TextEditInput::~TextEditInput () {
@@ -535,6 +539,9 @@ bool TextEditInput::edit(int key, int screenWidth, int charWidth) {
535539 case SB_KEY_TAB:
536540 editTab ();
537541 break ;
542+ case SB_KEY_F (4 ):
543+ toggleMarker ();
544+ break ;
538545 case SB_KEY_SHIFT (SB_KEY_PGUP):
539546 case SB_KEY_PGUP:
540547 pageNavigate (false , key == (int )SB_KEY_SHIFT (SB_KEY_PGUP));
@@ -799,7 +806,15 @@ void TextEditInput::cycleTheme() {
799806
800807void TextEditInput::drawLineNumber (int x, int y, int row, bool selected) {
801808 if (_marginWidth > 0 ) {
802- if (selected) {
809+ bool markerRow = false ;
810+ for (int i = 0 ; i < MAX_MARKERS && !markerRow; i++) {
811+ if (row == _lineMarker[i]) {
812+ markerRow = true ;
813+ }
814+ }
815+ if (markerRow) {
816+ maSetColor (_theme->_row_marker );
817+ } else if (selected) {
803818 maSetColor (_theme->_number_selection_background );
804819 maFillRect (x, y, _marginWidth, _charHeight);
805820 maSetColor (_theme->_number_selection_color );
@@ -1257,6 +1272,29 @@ void TextEditInput::setColor(SyntaxState &state) {
12571272 }
12581273}
12591274
1275+ void TextEditInput::toggleMarker () {
1276+ _cursorRow = getCursorRow ();
1277+ bool found = false ;
1278+ for (int i = 0 ; i < MAX_MARKERS && !found; i++) {
1279+ if (_cursorRow == _lineMarker[i]) {
1280+ _lineMarker[i] = -1 ;
1281+ found = true ;
1282+ }
1283+ }
1284+ if (!found) {
1285+ for (int i = 0 ; i < MAX_MARKERS && !found; i++) {
1286+ if (_lineMarker[i] == -1 ) {
1287+ _lineMarker[i] = _cursorRow;
1288+ found = true ;
1289+ break ;
1290+ }
1291+ }
1292+ }
1293+ if (!found) {
1294+ _lineMarker[0 ] = _cursorRow;
1295+ }
1296+ }
1297+
12601298void TextEditInput::updateScroll () {
12611299 int pageRows = _height / _charHeight;
12621300 if (_cursorRow + 1 < pageRows) {
0 commit comments