From: Michael D. Lowis Date: Mon, 12 Jun 2017 00:37:14 +0000 (-0400) Subject: Highlight current line number X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=7e5a3a15c4119f0b31855f0a87c214cb7ac0fea9;p=projs%2Ftide.git Highlight current line number --- diff --git a/config.h b/config.h index b5cb7e2..e11e1ca 100644 --- 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 diff --git a/lib/win.c b/lib/win.c index 76e72de..7f078fb 100644 --- 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;