]> git.mdlowis.com Git - projs/tide.git/commitdiff
Highlight current line number
authorMichael D. Lowis <mike@mdlowis.com>
Mon, 12 Jun 2017 00:37:14 +0000 (20:37 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Mon, 12 Jun 2017 00:37:14 +0000 (20:37 -0400)
config.h
lib/win.c

index b5cb7e2051bb47dce0c4a0f5339caa25a9c297fd..e11e1ca8b8217d520f75b41c5b94cb723bcac5a2 100644 (file)
--- a/config.h
+++ b/config.h
@@ -4,7 +4,7 @@ extern unsigned int ColorPalette[16];
 extern char *ShellCmd[], *SedCmd[], *PickFileCmd[], *PickTagCmd[], *OpenCmd[];
 extern int CLR_NormalText, CLR_GutterText, CLR_SelectedText, CLR_TagsBkg,
            CLR_EditBkg, CLR_HorBorder, CLR_VerBorder, CLR_Ruler, CLR_ScrollBkg,
-           CLR_ThumbBkg, CLR_Cursor, CLR_Comment;
+           CLR_ThumbBkg, CLR_Cursor, CLR_CurrentLine, CLR_Comment;
 
 /* OS-Specific Config
  ******************************************************************************/
@@ -92,7 +92,8 @@ int CLR_HorBorder    = 2;  // Horizontal border color
 int CLR_VerBorder    = 2;  // Vertical border color
 int CLR_Ruler        = 1;  // Ruler color
 int CLR_Cursor       = 7;  // Cursor color
-int CLR_Comment      = 2; // Comment color
+int CLR_CurrentLine  = 13; // Current Line Number
+int CLR_Comment      = 2;  // Comment color
 
 #undef INCLUDE_DEFS
 #endif
index 76e72de8a9bb4eb4a81cad91b37f0757b6316b87..7f078fb593026c78a27a72b101069951297d91c5 100644 (file)
--- a/lib/win.c
+++ b/lib/win.c
@@ -12,7 +12,7 @@ static void onmousedrag(int state, int x, int y);
 static void onmousebtn(int btn, bool pressed, int x, int y);
 static void onwheelup(WinRegion id, bool pressed, size_t row, size_t col);
 static void onwheeldn(WinRegion id, bool pressed, size_t row, size_t col);
-static void draw_line_num(size_t x, size_t y, size_t gcols, size_t num);
+static void draw_line_num(bool current, size_t x, size_t y, size_t gcols, size_t num);
 static void draw_glyphs(size_t x, size_t y, UGlyph* glyphs, size_t rlen, size_t ncols);
 static WinRegion getregion(size_t x, size_t y);
 
@@ -237,7 +237,12 @@ static void onredraw(int width, int height) {
         for (size_t line = 0, y = 0; y < view->nrows; y++) {
             Row* row = view_getrow(view, y);
             if (line != row->line)
-                draw_line_num(Regions[i].x - (gcols * fwidth) - 5, Regions[i].y + ((y+1) * fheight), gcols, row->line);
+                draw_line_num(
+                    (y == Regions[i].csry),
+                    Regions[i].x - (gcols * fwidth) - 5,
+                    Regions[i].y + ((y+1) * fheight),
+                    gcols,
+                    row->line);
             draw_glyphs(Regions[i].x, Regions[i].y + ((y+1) * fheight), row->cols, row->rlen, row->len);
             line = row->line;
         }
@@ -366,11 +371,12 @@ static void onwheeldn(WinRegion id, bool pressed, size_t row, size_t col) {
     view_scroll(win_view(id), +ScrollLines);
 }
 
-static void draw_line_num(size_t x, size_t y, size_t gcols, size_t num) {
+static void draw_line_num(bool current, size_t x, size_t y, size_t gcols, size_t num) {
     if (ShowLineNumbers) {
+        int color = (current ? CLR_CurrentLine : CLR_GutterText);
         UGlyph glyphs[gcols];
         for (int i = gcols-1; i >= 0; i--) {
-            glyphs[i].attr = CLR_GutterText;
+            glyphs[i].attr = color;
             if (num > 0) {
                 glyphs[i].rune = ((num % 10) + '0');
                 num /= 10;