diff options
author | mongo <andmarti@gmail.com> | 2017-04-06 11:59:22 -0300 |
---|---|---|
committer | mongo <andmarti@gmail.com> | 2017-04-06 11:59:22 -0300 |
commit | e9ada64136b15e15ef354280fb6643df40dea137 (patch) | |
tree | 4007da6543d138c63ab5445677375d529dba5da9 /src/help.c | |
parent | a80288e0a2110b5b8c7362f8ee3b28a69d99d870 (diff) |
Added colors to help
Diffstat (limited to 'src/help.c')
-rw-r--r-- | src/help.c | 49 |
1 files changed, 38 insertions, 11 deletions
@@ -1,4 +1,4 @@ -#ifdef CURSES +#ifdef NCURSES #include <ncurses.h> #include <unistd.h> #include <stdlib.h> @@ -279,7 +279,7 @@ void find_word(char * word, char order) { } int show_lines() { - int lineno, c = 0, bold = 0; + int lineno, i, k, key = 0, bold = 0 ; for (lineno = 0; long_help[lineno + delta] && lineno < LINES - RESROW; lineno++) { if (strlen(word_looked)) look_result = str_in_str(long_help[lineno + delta], word_looked); @@ -287,18 +287,45 @@ int show_lines() { wmove(main_win, lineno, 0); wclrtoeol(main_win); - for (c = 0; c < strlen(long_help[lineno + delta]); c++) { - if (long_help[lineno + delta][c] == '&') bold = ! bold; - bold ? ui_set_ucolor(main_win, &ucolors[CELL_SELECTION_SC]) : ui_set_ucolor(main_win, &ucolors[NORMAL]); + for (i=0; long_help[lineno + delta][i] != '\0'; i++) { - if (long_help[lineno + delta][c] == '&') { - ui_set_ucolor(main_win, &ucolors[NORMAL]); + if (long_help[lineno + delta][i] == '&') bold = ! bold; + + #ifdef USECOLORS + bold && ! key? + ui_set_ucolor(main_win, &ucolors[CELL_SELECTION_SC]) : + ui_set_ucolor(main_win, &ucolors[NORMAL]); + #endif + + if (long_help[lineno + delta][i] == '<' || long_help[lineno + delta][i] == '{') { + // do not colorize if not '>' or '}' in line + for (key = 1, k=i; long_help[lineno + delta][k] != '\0'; k++) { + if (long_help[lineno + delta][k] == '\'') { key = 0; break; } + else if (long_help[lineno + delta][k] == ';') { key = 0; break; } + else if (long_help[lineno + delta][k] == '>') { break; } + else if (long_help[lineno + delta][k] == '}') { break; } + else if (long_help[lineno + delta][k+1] == '\0') { key = 0; break; } + } + } + + if (long_help[lineno + delta][i] == '&') { + #ifdef USECOLORS + ui_set_ucolor(main_win, &ucolors[NORMAL]); + #endif continue; - } else if (look_result != -1 && c >= look_result && - c < look_result + strlen(word_looked) ) { - ui_set_ucolor(main_win, &ucolors[CELL_SELECTION_SC]); + } else if (look_result != -1 && i >= look_result && + i < look_result + strlen(word_looked) ) { + #ifdef USECOLORS + ui_set_ucolor(main_win, &ucolors[CELL_SELECTION_SC]); + #endif + } else if (key) { + #ifdef USECOLORS + ui_set_ucolor(main_win, &ucolors[NUMB]); + #endif } - mvwprintw(main_win, lineno, c, "%c", long_help[lineno + delta][c]); + + mvwprintw(main_win, lineno, i, "%c", long_help[lineno + delta][i]); + if (long_help[lineno + delta][i] == '>' || long_help[lineno + delta][i] == '}') key = 0; } wclrtoeol(main_win); } |