From 5203d6739d103ada0072ebcce4e6a4120de132cf Mon Sep 17 00:00:00 2001 From: Ilia Maslakov Date: Thu, 19 Nov 2009 15:35:00 +0300 Subject: [PATCH] Ticket #1514 (show right margin) * added new color pair EDITOR_RIGHT_MARGIN_COLOR * show right margin. Used EDITOR_RIGHT_MARGIN_COLOR color for drawing text beyond rigth edge. Signed-off-by: Ilia Maslakov --- edit/editdraw.c | 18 +++++++++++++++--- misc/skins/darkfar.ini | 1 + misc/skins/default.ini | 1 + misc/skins/double-lines.ini | 1 + src/skin/colors.c | 2 ++ src/skin/skin.h | 13 +++++++------ 6 files changed, 27 insertions(+), 9 deletions(-) diff --git a/edit/editdraw.c b/edit/editdraw.c index 64572275e..ca8c7996a 100644 --- a/edit/editdraw.c +++ b/edit/editdraw.c @@ -288,9 +288,18 @@ print_to_widget (WEdit *edit, long row, int start_col, int start_col_real, int y = row + EDIT_TEXT_VERTICAL_OFFSET; int cols_to_skip = abs (x); + if (-edit->start_col < option_word_wrap_line_length) { tty_setcolor (EDITOR_NORMAL_COLOR); - tty_draw_hline (edit->widget.y + y, edit->widget.x + x1, - ' ', end_col + 1 - start_col); + tty_draw_hline (edit->widget.y + y, + edit->widget.x + x1, + ' ', + option_word_wrap_line_length - edit->start_col); + } + tty_setcolor (EDITOR_RIGHT_MARGIN_COLOR); + tty_draw_hline (edit->widget.y + y, + edit->widget.x + x1 + option_word_wrap_line_length + edit->start_col, + ' ', + end_col + 1 - start_col); if (option_line_state) { int i; @@ -305,7 +314,7 @@ print_to_widget (WEdit *edit, long row, int start_col, int start_col_real, edit_move (x1 + FONT_OFFSET_X, y + FONT_OFFSET_Y); p = line; - + int i = 1; while (p->ch) { int style; unsigned int textchar; @@ -348,8 +357,11 @@ print_to_widget (WEdit *edit, long row, int start_col, int start_col_real, tty_lowlevel_setcolor (color); } } + if (i > option_word_wrap_line_length + edit->start_col) + tty_setcolor (EDITOR_RIGHT_MARGIN_COLOR); tty_print_anychar (textchar); p++; + i++; } } diff --git a/misc/skins/darkfar.ini b/misc/skins/darkfar.ini index 321d441ec..5a0ac9a2b 100644 --- a/misc/skins/darkfar.ini +++ b/misc/skins/darkfar.ini @@ -73,6 +73,7 @@ linestate=white;cyan bookmark=white;red bookmarkfound=black;green + editrightmargin=white;blue [viewer] viewunderline=brightred;black diff --git a/misc/skins/default.ini b/misc/skins/default.ini index 2054b6632..b1c1219c3 100644 --- a/misc/skins/default.ini +++ b/misc/skins/default.ini @@ -78,6 +78,7 @@ linestate=white;cyan bookmark=white;red bookmarkfound=black;green + editbeyondwrap=brightblue;black [viewer] viewunderline=brightred;blue diff --git a/misc/skins/double-lines.ini b/misc/skins/double-lines.ini index c8225625b..3f571aaad 100644 --- a/misc/skins/double-lines.ini +++ b/misc/skins/double-lines.ini @@ -74,6 +74,7 @@ linestate=white;cyan bookmark=white;red bookmarkfound=black;green + editbeyondwrap=brightblue;black [viewer] viewunderline=brightred;blue diff --git a/src/skin/colors.c b/src/skin/colors.c index ba2082b0e..ff38735d8 100644 --- a/src/skin/colors.c +++ b/src/skin/colors.c @@ -226,7 +226,9 @@ mc_skin_color_cache_init (void) EDITOR_BOLD_COLOR = mc_skin_color_get ("editor", "editbold"); EDITOR_MARKED_COLOR = mc_skin_color_get ("editor", "editmarked"); EDITOR_WHITESPACE_COLOR = mc_skin_color_get ("editor", "editwhitespace"); + EDITOR_RIGHT_MARGIN_COLOR = mc_skin_color_get ("editor", "editrightmargin"); LINE_STATE_COLOR = mc_skin_color_get ("editor", "linestate"); + BOOK_MARK_COLOR = mc_skin_color_get ("editor", "bookmark"); BOOK_MARK_FOUND_COLOR = mc_skin_color_get ("editor", "bookmarkfound"); BUTTONBAR_HOTKEY_COLOR = mc_skin_color_get ("buttonbar", "hotkey"); diff --git a/src/skin/skin.h b/src/skin/skin.h index 499f0feeb..ae11ed4f2 100644 --- a/src/skin/skin.h +++ b/src/skin/skin.h @@ -61,15 +61,16 @@ #define EDITOR_BOLD_COLOR mc_skin_color__cache[26] #define EDITOR_MARKED_COLOR mc_skin_color__cache[27] #define EDITOR_WHITESPACE_COLOR mc_skin_color__cache[28] +#define EDITOR_RIGHT_MARGIN_COLOR mc_skin_color__cache[29] /* color of left 8 char status per line */ -#define LINE_STATE_COLOR mc_skin_color__cache[29] -#define BOOK_MARK_COLOR mc_skin_color__cache[30] -#define BOOK_MARK_FOUND_COLOR mc_skin_color__cache[31] +#define LINE_STATE_COLOR mc_skin_color__cache[30] +#define BOOK_MARK_COLOR mc_skin_color__cache[31] +#define BOOK_MARK_FOUND_COLOR mc_skin_color__cache[32] -#define BUTTONBAR_HOTKEY_COLOR mc_skin_color__cache[32] -#define BUTTONBAR_BUTTON_COLOR mc_skin_color__cache[33] +#define BUTTONBAR_HOTKEY_COLOR mc_skin_color__cache[33] +#define BUTTONBAR_BUTTON_COLOR mc_skin_color__cache[34] -#define MC_SKIN_COLOR_CACHE_COUNT 34 +#define MC_SKIN_COLOR_CACHE_COUNT 35 /*** enums ***************************************************************************************/