diff options
Diffstat (limited to 'src/fe-text')
-rw-r--r-- | src/fe-text/gui-entry.c | 6 | ||||
-rw-r--r-- | src/fe-text/gui-printtext.c | 7 | ||||
-rw-r--r-- | src/fe-text/gui-readline.c | 25 | ||||
-rw-r--r-- | src/fe-text/irssi.c | 26 | ||||
-rw-r--r-- | src/fe-text/lastlog.c | 31 | ||||
-rw-r--r-- | src/fe-text/mainwindows-layout.c | 3 | ||||
-rw-r--r-- | src/fe-text/module-formats.c | 1 | ||||
-rw-r--r-- | src/fe-text/module-formats.h | 1 | ||||
-rw-r--r-- | src/fe-text/statusbar-config.c | 24 | ||||
-rw-r--r-- | src/fe-text/statusbar-items.c | 10 | ||||
-rw-r--r-- | src/fe-text/statusbar.c | 4 | ||||
-rw-r--r-- | src/fe-text/term-terminfo.c | 35 | ||||
-rw-r--r-- | src/fe-text/term.h | 2 | ||||
-rw-r--r-- | src/fe-text/terminfo-core.c | 120 | ||||
-rw-r--r-- | src/fe-text/terminfo-core.h | 4 | ||||
-rw-r--r-- | src/fe-text/tparm.c | 12 |
16 files changed, 182 insertions, 129 deletions
diff --git a/src/fe-text/gui-entry.c b/src/fe-text/gui-entry.c index 309f3a68..306141ec 100644 --- a/src/fe-text/gui-entry.c +++ b/src/fe-text/gui-entry.c @@ -36,21 +36,21 @@ static unichar i_toupper(unichar c) { if (term_type == TERM_TYPE_UTF8) return g_unichar_toupper(c); - return (c >= 0 && c <= 255) ? toupper(c) : c; + return c <= 255 ? toupper(c) : c; } static unichar i_tolower(unichar c) { if (term_type == TERM_TYPE_UTF8) return g_unichar_tolower(c); - return (c >= 0 && c <= 255) ? tolower(c) : c; + return c <= 255 ? tolower(c) : c; } static int i_isalnum(unichar c) { if (term_type == TERM_TYPE_UTF8) return (g_unichar_isalnum(c) || mk_wcwidth(c) == 0); - return (c >= 0 && c <= 255) ? isalnum(c) : 0; + return c <= 255 ? isalnum(c) : 0; } GUI_ENTRY_REC *active_entry; diff --git a/src/fe-text/gui-printtext.c b/src/fe-text/gui-printtext.c index 83b26e82..775e6044 100644 --- a/src/fe-text/gui-printtext.c +++ b/src/fe-text/gui-printtext.c @@ -230,16 +230,15 @@ static void sig_gui_print_text(WINDOW_REC *window, void *fgcolor, get_colors(flags, &fg, &bg, &attr); if (window == NULL) { - g_return_if_fail(next_xpos != -1); + g_return_if_fail(next_xpos != -1); term_set_color2(root_window, attr, fg, bg); term_move(root_window, next_xpos, next_ypos); if (flags & GUI_PRINT_FLAG_CLRTOEOL) term_clrtoeol(root_window); - term_addstr(root_window, str); - next_xpos += strlen(str); /* FIXME utf8 or big5 */ - return; + next_xpos += term_addstr(root_window, str); + return; } lineinfo.level = dest == NULL ? 0 : dest->level; diff --git a/src/fe-text/gui-readline.c b/src/fe-text/gui-readline.c index 476a798b..a8f3ba99 100644 --- a/src/fe-text/gui-readline.c +++ b/src/fe-text/gui-readline.c @@ -147,7 +147,6 @@ static void window_next_page(void) static void paste_buffer_join_lines(GArray *buf) { -#define IS_WHITE(c) ((c) == ' ' || (c) == '\t') unsigned int i, count, indent, line_len; unichar *arr, *dest, *last_lf_pos; int last_lf; @@ -177,15 +176,15 @@ static void paste_buffer_join_lines(GArray *buf) if (buf->len == 0) return; - arr = (unichar *) paste_buffer->data; + arr = (unichar *)buf->data; /* first line */ - if (IS_WHITE(arr[0])) + if (isblank(arr[0])) return; /* find the first beginning of indented line */ for (i = 1; i < buf->len; i++) { - if (arr[i-1] == '\n' && IS_WHITE(arr[i])) + if (arr[i-1] == '\n' && isblank(arr[i])) break; } if (i == buf->len) @@ -193,7 +192,7 @@ static void paste_buffer_join_lines(GArray *buf) /* get how much indentation we have.. */ for (indent = 0; i < buf->len; i++, indent++) { - if (!IS_WHITE(arr[i])) + if (!isblank(arr[i])) break; } if (i == buf->len) @@ -203,7 +202,7 @@ static void paste_buffer_join_lines(GArray *buf) count = indent; last_lf = TRUE; for (; i < buf->len; i++) { if (last_lf) { - if (IS_WHITE(arr[i])) + if (isblank(arr[i])) count++; else { last_lf = FALSE; @@ -220,11 +219,11 @@ static void paste_buffer_join_lines(GArray *buf) get longer than 400 chars */ dest = arr; last_lf = TRUE; last_lf_pos = NULL; line_len = 0; for (i = 0; i < buf->len; i++) { - if (last_lf && IS_WHITE(arr[i])) { + if (last_lf && isblank(arr[i])) { /* whitespace, ignore */ } else if (arr[i] == '\n') { if (!last_lf && i+1 != buf->len && - IS_WHITE(arr[i+1])) { + isblank(arr[i+1])) { last_lf_pos = dest; *dest++ = ' '; } else { @@ -237,7 +236,7 @@ static void paste_buffer_join_lines(GArray *buf) last_lf = FALSE; if (++line_len >= 400 && last_lf_pos != NULL) { memmove(last_lf_pos+1, last_lf_pos, - dest - last_lf_pos); + (dest - last_lf_pos) * sizeof(unichar)); *last_lf_pos = '\n'; last_lf_pos = NULL; line_len = 0; dest++; @@ -392,9 +391,9 @@ static void sig_gui_key_pressed(gpointer keyp) str[g_unichar_to_utf8(key, str)] = '\0'; } - if (strcmp(str, "^") == 0) { - /* change it as ^^ */ - str[1] = '^'; + if (g_strcmp0(str, "^") == 0) { + /* change it as ^-, that is an invalid control char */ + str[1] = '-'; str[2] = '\0'; } @@ -1020,6 +1019,8 @@ void gui_readline_init(void) key_bind("key", NULL, "meta2-5F", "cend", (SIGNAL_FUNC) key_combo); key_bind("key", NULL, "meta2-1;5F", "cend", (SIGNAL_FUNC) key_combo); + key_bind("key", NULL, "meta-O-M", "return", (SIGNAL_FUNC) key_combo); + /* cursor movement */ key_bind("backward_character", "Move the cursor a character backward", "left", NULL, (SIGNAL_FUNC) key_backward_character); key_bind("forward_character", "Move the cursor a character forward", "right", NULL, (SIGNAL_FUNC) key_forward_character); diff --git a/src/fe-text/irssi.c b/src/fe-text/irssi.c index 77033d7a..b1fa5e22 100644 --- a/src/fe-text/irssi.c +++ b/src/fe-text/irssi.c @@ -286,22 +286,6 @@ static void winsock_init(void) } #endif -#ifdef USE_GC -#ifdef HAVE_GC_H -# include <gc.h> -#else -# include <gc/gc.h> -#endif - -GMemVTable gc_mem_table = { - GC_malloc, - GC_realloc, - GC_free, - - NULL, NULL, NULL -}; -#endif - int main(int argc, char **argv) { static int version = 0; @@ -310,10 +294,7 @@ int main(int argc, char **argv) { "version", 'v', 0, G_OPTION_ARG_NONE, &version, "Display irssi version", NULL }, { NULL } }; - -#ifdef USE_GC - g_mem_set_vtable(&gc_mem_table); -#endif + int loglev; core_register_options(); fe_common_core_register_options(); @@ -352,6 +333,7 @@ int main(int argc, char **argv) you have to call setlocale(LC_ALL, "") */ setlocale(LC_ALL, ""); + loglev = g_log_set_always_fatal(G_LOG_FATAL_MASK | G_LOG_LEVEL_CRITICAL); textui_init(); if (!dummy && !term_init()) { @@ -360,15 +342,13 @@ int main(int argc, char **argv) return 1; } + g_log_set_always_fatal(loglev); textui_finish_init(); main_loop = g_main_new(TRUE); /* Does the same as g_main_run(main_loop), except we can call our dirty-checker after each iteration */ while (!quitting) { -#ifdef USE_GC - GC_collect_a_little(); -#endif if (!dummy) term_refresh_freeze(); g_main_iteration(TRUE); if (!dummy) term_refresh_thaw(); diff --git a/src/fe-text/lastlog.c b/src/fe-text/lastlog.c index 417eb484..166d2847 100644 --- a/src/fe-text/lastlog.c +++ b/src/fe-text/lastlog.c @@ -74,6 +74,25 @@ int cmd_options_get_level(const char *cmd, GHashTable *optlist) return retlevel; } +static void prepend_date(WINDOW_REC *window, LINE_REC *rec, GString *line) +{ + THEME_REC *theme = NULL; + TEXT_DEST_REC dest = {0}; + char *format = NULL, datestamp[20] = {0}; + struct tm *tm = localtime(&rec->info.time); + int ret = 0; + + theme = window->theme != NULL ? window->theme : current_theme; + format_create_dest(&dest, NULL, NULL, MSGLEVEL_LASTLOG, window); + format = format_get_text_theme(theme, MODULE_NAME, &dest, TXT_LASTLOG_DATE); + + ret = strftime(datestamp, sizeof(datestamp), format, tm); + g_free(format); + if (ret <= 0) return; + + g_string_prepend(line, datestamp); +} + static void show_lastlog(const char *searchtext, GHashTable *optlist, int start, int count, FILE *fhandle) { @@ -82,7 +101,7 @@ static void show_lastlog(const char *searchtext, GHashTable *optlist, GList *list, *tmp; GString *line; char *str; - int level, before, after, len; + int level, before, after, len, date = FALSE; level = cmd_options_get_level("lastlog", optlist); if (level == -1) return; /* error in options */ @@ -132,6 +151,9 @@ static void show_lastlog(const char *searchtext, GHashTable *optlist, atoi(str) : DEFAULT_LASTLOG_AFTER; } + if (g_hash_table_lookup(optlist, "date") != NULL) + date = TRUE; + list = textbuffer_find_text(WINDOW_GUI(window)->view->buffer, startline, level, MSGLEVEL_LASTLOG, searchtext, before, after, @@ -199,6 +221,9 @@ static void show_lastlog(const char *searchtext, GHashTable *optlist, g_string_prepend(line, timestamp); } + if (date == TRUE) + prepend_date(window, rec, line); + /* write to file/window */ if (fhandle != NULL) { fwrite(line->str, line->len, 1, fhandle); @@ -223,7 +248,7 @@ static void show_lastlog(const char *searchtext, GHashTable *optlist, } /* SYNTAX: LASTLOG [-] [-file <filename>] [-window <ref#|name>] [-new | -away] - [-<level> -<level...>] [-clear] [-count] [-case] + [-<level> -<level...>] [-clear] [-count] [-case] [-date] [-regexp | -word] [-before [<#>]] [-after [<#>]] [-<# before+after>] [<pattern>] [<count> [<start>]] */ static void cmd_lastlog(const char *data) @@ -285,7 +310,7 @@ void lastlog_init(void) { command_bind("lastlog", NULL, (SIGNAL_FUNC) cmd_lastlog); - command_set_options("lastlog", "!- # force clear -file -window new away word regexp case count @a @after @before"); + command_set_options("lastlog", "!- # force clear -file -window new away word regexp case count date @a @after @before"); } void lastlog_deinit(void) diff --git a/src/fe-text/mainwindows-layout.c b/src/fe-text/mainwindows-layout.c index 28fae924..020969e6 100644 --- a/src/fe-text/mainwindows-layout.c +++ b/src/fe-text/mainwindows-layout.c @@ -70,7 +70,7 @@ static void main_window_save(MAIN_WINDOW_REC *window, CONFIG_NODE *node) char num[MAX_INT_STRLEN]; ltoa(num, window->active->refnum); - node = config_node_section(node, num, NODE_TYPE_BLOCK); + node = iconfig_node_section(node, num, NODE_TYPE_BLOCK); iconfig_node_set_int(node, "first_line", window->first_line); iconfig_node_set_int(node, "lines", window->height); @@ -179,6 +179,7 @@ static void sig_layout_restore(void) lower_window = NULL; lower_size = 0; for (i = 0, tmp = sorted_config; i < windows_count; tmp = tmp->next, i++) { CONFIG_NODE *node = tmp->data; + if (node->key == NULL) continue; /* create a new window + mainwindow */ signal_emit("gui window create override", 1, diff --git a/src/fe-text/module-formats.c b/src/fe-text/module-formats.c index 1d905095..899827c2 100644 --- a/src/fe-text/module-formats.c +++ b/src/fe-text/module-formats.c @@ -33,6 +33,7 @@ FORMAT_REC gui_text_formats[] = { "lastlog_start", "{hilight Lastlog}:", 0 }, { "lastlog_end", "{hilight End of Lastlog}", 0 }, { "lastlog_separator", "--", 0 }, + { "lastlog_date", "%%F ", 0 }, /* ---- */ { NULL, "Windows", 0 }, diff --git a/src/fe-text/module-formats.h b/src/fe-text/module-formats.h index 4eebfc3e..3fa8c511 100644 --- a/src/fe-text/module-formats.h +++ b/src/fe-text/module-formats.h @@ -10,6 +10,7 @@ enum { TXT_LASTLOG_START, TXT_LASTLOG_END, TXT_LASTLOG_SEPARATOR, + TXT_LASTLOG_DATE, TXT_FILL_2, diff --git a/src/fe-text/statusbar-config.c b/src/fe-text/statusbar-config.c index deaa1b5d..a47a709e 100644 --- a/src/fe-text/statusbar-config.c +++ b/src/fe-text/statusbar-config.c @@ -95,7 +95,7 @@ statusbar_config_find(STATUSBAR_GROUP_REC *group, const char *name) for (tmp = group->config_bars; tmp != NULL; tmp = tmp->next) { STATUSBAR_CONFIG_REC *config = tmp->data; - if (strcmp(config->name, name) == 0) + if (g_strcmp0(config->name, name) == 0) return config; } @@ -137,7 +137,7 @@ static void statusbar_read_item(STATUSBAR_CONFIG_REC *bar, CONFIG_NODE *node) int priority, right_alignment; priority = config_node_get_int(node, "priority", 0); - right_alignment = strcmp(config_node_get_str(node, "alignment", ""), "right") == 0; + right_alignment = g_strcmp0(config_node_get_str(node, "alignment", ""), "right") == 0; statusbar_item_config_create(bar, node->key, priority, right_alignment); } @@ -177,7 +177,7 @@ static void statusbar_read(STATUSBAR_GROUP_REC *group, CONFIG_NODE *node) bar->placement = STATUSBAR_TOP; bar->position = config_node_get_int(node, "position", 0); - node = config_node_section(node, "items", -1); + node = iconfig_node_section(node, "items", -1); if (node != NULL) { /* we're overriding the items - destroy the old */ while (bar->items != NULL) @@ -227,7 +227,7 @@ static void read_statusbar_config_from_node(CONFIG_NODE *node) CONFIG_NODE *items; GSList *tmp; - items = config_node_section(node, "items", -1); + items = iconfig_node_section(node, "items", -1); if (items != NULL) statusbar_read_items(items); @@ -369,7 +369,7 @@ static void cmd_statusbar_reset(const char *data, void *server, CONFIG_NODE *parent; parent = iconfig_node_traverse("statusbar", TRUE); - parent = config_node_section(parent, active_statusbar_group->name, + parent = iconfig_node_section(parent, active_statusbar_group->name, NODE_TYPE_BLOCK); iconfig_node_set_str(parent, node->key, NULL); @@ -432,7 +432,7 @@ static CONFIG_NODE *statusbar_items_section(CONFIG_NODE *parent) CONFIG_NODE *node; GSList *tmp; - node = config_node_section(parent, "items", -1); + node = iconfig_node_section(parent, "items", -1); if (node != NULL) return node; @@ -446,11 +446,11 @@ static CONFIG_NODE *statusbar_items_section(CONFIG_NODE *parent) /* since items list in config file overrides defaults, we'll need to copy the whole list. */ - parent = config_node_section(parent, "items", NODE_TYPE_BLOCK); + parent = iconfig_node_section(parent, "items", NODE_TYPE_BLOCK); for (tmp = bar->items; tmp != NULL; tmp = tmp->next) { SBAR_ITEM_CONFIG_REC *rec = tmp->data; - node = config_node_section(parent, rec->name, + node = iconfig_node_section(parent, rec->name, NODE_TYPE_BLOCK); if (rec->priority != 0) iconfig_node_set_int(node, "priority", rec->priority); @@ -487,7 +487,7 @@ static void cmd_statusbar_add(const char *data, void *server, if (value != NULL) index = config_node_index(node, value)+1; /* create/move item */ - node = config_node_section_index(node, name, index, NODE_TYPE_BLOCK); + node = iconfig_node_section_index(node, name, index, NODE_TYPE_BLOCK); /* set the options */ value = g_hash_table_lookup(optlist, "priority"); @@ -511,7 +511,7 @@ static void cmd_statusbar_remove(const char *data, void *server, if (node == NULL) return; - if (config_node_section(node, data, -1) != NULL) + if (iconfig_node_section(node, data, -1) != NULL) iconfig_node_set_str(node, data, NULL); else { printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, @@ -545,9 +545,9 @@ static void cmd_statusbar(const char *data) /* lookup/create the statusbar node */ node = iconfig_node_traverse("statusbar", TRUE); - node = config_node_section(node, active_statusbar_group->name, + node = iconfig_node_section(node, active_statusbar_group->name, NODE_TYPE_BLOCK); - node = config_node_section(node, name, NODE_TYPE_BLOCK); + node = iconfig_node_section(node, name, NODE_TYPE_BLOCK); /* call the subcommand */ signal = g_strconcat("command statusbar ", cmd, NULL); diff --git a/src/fe-text/statusbar-items.c b/src/fe-text/statusbar-items.c index 044c2fa0..e3e0c2a6 100644 --- a/src/fe-text/statusbar-items.c +++ b/src/fe-text/statusbar-items.c @@ -347,10 +347,14 @@ static void item_lag(SBAR_ITEM_REC *item, int get_size_only) last_lag_unknown = lag_unknown; if (lag_unknown) { - g_snprintf(str, sizeof(str), "%d (?""?)", lag/100); + // "??)" in C becomes ']' + // See: https://en.wikipedia.org/wiki/Digraphs_and_trigraphs#C + g_snprintf(str, sizeof(str), "%d (?""?)", lag / 100); } else { - g_snprintf(str, sizeof(str), - lag%100 == 0 ? "%d" : "%d.%02d", lag/100, lag%100); + if (lag % 100 == 0) + g_snprintf(str, sizeof(str), "%d", lag / 100); + else + g_snprintf(str, sizeof(str), "%d.%02d", lag / 100, lag % 100); } statusbar_item_default_handler(item, get_size_only, diff --git a/src/fe-text/statusbar.c b/src/fe-text/statusbar.c index b340553f..5448243a 100644 --- a/src/fe-text/statusbar.c +++ b/src/fe-text/statusbar.c @@ -129,7 +129,7 @@ STATUSBAR_GROUP_REC *statusbar_group_find(const char *name) for (tmp = statusbar_groups; tmp != NULL; tmp = tmp->next) { STATUSBAR_GROUP_REC *rec = tmp->data; - if (strcmp(rec->name, name) == 0) + if (g_strcmp0(rec->name, name) == 0) return rec; } @@ -617,7 +617,7 @@ STATUSBAR_REC *statusbar_find(STATUSBAR_GROUP_REC *group, const char *name, STATUSBAR_REC *rec = tmp->data; if (rec->parent_window == window && - strcmp(rec->config->name, name) == 0) + g_strcmp0(rec->config->name, name) == 0) return rec; } diff --git a/src/fe-text/term-terminfo.c b/src/fe-text/term-terminfo.c index 29d3f7eb..27be904e 100644 --- a/src/fe-text/term-terminfo.c +++ b/src/fe-text/term-terminfo.c @@ -390,7 +390,8 @@ void term_set_color(TERM_WINDOW *window, int col) } /* set background color */ - if (window && (term_color256map[bg&0xff]&8) == window->term->TI_colors) + if (window && window->term->TI_colors && + (term_color256map[bg&0xff]&8) == window->term->TI_colors) col |= ATTR_BLINK; if (col & ATTR_BLINK) current_term->set_blink(current_term); @@ -413,7 +414,8 @@ void term_set_color(TERM_WINDOW *window, int col) terminfo_set_reverse(); /* bold */ - if (window && (term_color256map[fg&0xff]&8) == window->term->TI_colors) + if (window && window->term->TI_colors && + (term_color256map[fg&0xff]&8) == window->term->TI_colors) col |= ATTR_BOLD; if (col & ATTR_BOLD) terminfo_set_bold(); @@ -520,15 +522,36 @@ void term_add_unichar(TERM_WINDOW *window, unichar chr) } } -void term_addstr(TERM_WINDOW *window, const char *str) +int term_addstr(TERM_WINDOW *window, const char *str) { - int len; + int len, raw_len; + unichar tmp; + const char *ptr; if (vcmove) term_move_real(); - len = strlen(str); /* FIXME utf8 or big5 */ + + len = 0; + raw_len = strlen(str); + + /* The string length depends on the terminal encoding */ + + ptr = str; + + if (term_type == TERM_TYPE_UTF8) { + while (*ptr != '\0') { + tmp = g_utf8_get_char(ptr); + len += unichar_isprint(tmp) ? mk_wcwidth(tmp) : 1; + ptr = g_utf8_next_char(ptr); + } + } else + len = raw_len; + term_printed_text(len); - fwrite(str, 1, len, window->term->out); + /* Use strlen() here since we need the number of raw bytes */ + fwrite(str, 1, raw_len, window->term->out); + + return len; } void term_clrtoeol(TERM_WINDOW *window) diff --git a/src/fe-text/term.h b/src/fe-text/term.h index cdcc787a..f0a76c42 100644 --- a/src/fe-text/term.h +++ b/src/fe-text/term.h @@ -83,7 +83,7 @@ void term_set_color(TERM_WINDOW *window, int col); void term_move(TERM_WINDOW *window, int x, int y); void term_addch(TERM_WINDOW *window, char chr); void term_add_unichar(TERM_WINDOW *window, unichar chr); -void term_addstr(TERM_WINDOW *window, const char *str); +int term_addstr(TERM_WINDOW *window, const char *str); void term_clrtoeol(TERM_WINDOW *window); void term_move_cursor(int x, int y); diff --git a/src/fe-text/terminfo-core.c b/src/fe-text/terminfo-core.c index d16987fe..60927f1a 100644 --- a/src/fe-text/terminfo-core.c +++ b/src/fe-text/terminfo-core.c @@ -50,62 +50,66 @@ TERM_REC *current_term; /* Define only what we might need */ static TERMINFO_REC tcaps[] = { - /* Terminal size */ - { "cols", "co", CAP_TYPE_INT, G_STRUCT_OFFSET(TERM_REC, width) }, - { "lines", "li", CAP_TYPE_INT, G_STRUCT_OFFSET(TERM_REC, height) }, - - /* Cursor movement */ - { "smcup", "ti", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_smcup) }, - { "rmcup", "te", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_rmcup) }, - { "cup", "cm", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_cup) }, - { "hpa", "ch", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_hpa) }, - { "vpa", "vh", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_vpa) }, - { "cub1", "le", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_cub1) }, - { "cuf1", "nd", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_cuf1) }, - { "civis", "vi", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_civis) }, - { "cnorm", "ve", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_cnorm) }, + /* Terminal size */ + { "cols", "co", CAP_TYPE_INT, G_STRUCT_OFFSET(TERM_REC, width) }, + { "lines", "li", CAP_TYPE_INT, G_STRUCT_OFFSET(TERM_REC, height) }, - /* Scrolling */ - { "csr", "cs", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_csr) }, - { "wind", "wi", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_wind) }, - { "ri", "sr", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_ri) }, - { "rin", "SR", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_rin) }, - { "ind", "sf", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_ind) }, - { "indn", "SF", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_indn) }, - { "il", "AL", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_il) }, - { "il1", "al", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_il1) }, - { "dl", "DL", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_dl) }, - { "dl1", "dl", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_dl1) }, + /* Cursor movement */ + { "smcup", "ti", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_smcup) }, + { "rmcup", "te", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_rmcup) }, + { "cup", "cm", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_cup) }, + { "hpa", "ch", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_hpa) }, + { "vpa", "vh", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_vpa) }, + { "cub1", "le", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_cub1) }, + { "cuf1", "nd", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_cuf1) }, + { "civis", "vi", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_civis) }, + { "cnorm", "ve", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_cnorm) }, + + /* Scrolling */ + { "csr", "cs", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_csr) }, + { "wind", "wi", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_wind) }, + { "ri", "sr", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_ri) }, + { "rin", "SR", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_rin) }, + { "ind", "sf", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_ind) }, + { "indn", "SF", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_indn) }, + { "il", "AL", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_il) }, + { "il1", "al", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_il1) }, + { "dl", "DL", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_dl) }, + { "dl1", "dl", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_dl1) }, /* Clearing screen */ - { "clear", "cl", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_clear) }, - { "ed", "cd", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_ed) }, + { "clear", "cl", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_clear) }, + { "ed", "cd", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_ed) }, - /* Clearing to end of line */ - { "el", "ce", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_el) }, + /* Clearing to end of line */ + { "el", "ce", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_el) }, - /* Repeating character */ - { "rep", "rp", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_rep) }, + /* Repeating character */ + { "rep", "rp", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_rep) }, /* Colors */ - { "colors", "Co", CAP_TYPE_INT, G_STRUCT_OFFSET(TERM_REC, TI_colors) }, - { "sgr0", "me", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_sgr0) }, - { "smul", "us", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_smul) }, - { "rmul", "ue", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_rmul) }, - { "smso", "so", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_smso) }, - { "rmso", "se", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_rmso) }, - { "sitm", "ZH", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_sitm) }, - { "ritm", "ZR", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_ritm) }, - { "bold", "md", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_bold) }, - { "blink", "mb", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_blink) }, - { "rev", "mr", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_rev) }, - { "setaf", "AF", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_setaf) }, - { "setab", "AB", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_setab) }, - { "setf", "Sf", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_setf) }, - { "setb", "Sb", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_setb) }, - - /* Beep */ - { "bel", "bl", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_bel) }, + { "colors", "Co", CAP_TYPE_INT, G_STRUCT_OFFSET(TERM_REC, TI_colors) }, + { "sgr0", "me", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_sgr0) }, + { "smul", "us", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_smul) }, + { "rmul", "ue", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_rmul) }, + { "smso", "so", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_smso) }, + { "rmso", "se", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_rmso) }, + { "sitm", "ZH", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_sitm) }, + { "ritm", "ZR", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_ritm) }, + { "bold", "md", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_bold) }, + { "blink", "mb", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_blink) }, + { "rev", "mr", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_rev) }, + { "setaf", "AF", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_setaf) }, + { "setab", "AB", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_setab) }, + { "setf", "Sf", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_setf) }, + { "setb", "Sb", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_setb) }, + + /* Beep */ + { "bel", "bl", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_bel) }, + + /* Keyboard-transmit mode */ + { "smkx", "ks", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_smkx) }, + { "rmkx", "ke", CAP_TYPE_STR, G_STRUCT_OFFSET(TERM_REC, TI_rmkx) }, }; /* Move cursor (cursor_address / cup) */ @@ -498,6 +502,9 @@ static void terminfo_input_init(TERM_REC *term) memcpy(&term->tio, &term->old_tio, sizeof(term->tio)); term->tio.c_lflag &= ~(ICANON | ECHO); /* CBREAK, no ECHO */ + /* Disable the ICRNL flag to disambiguate ^J and Enter, also disable the + * software flow control to leave ^Q and ^S ready to be bound */ + term->tio.c_iflag &= ~(ICRNL | IXON | IXOFF); term->tio.c_cc[VMIN] = 1; /* read() is satisfied after 1 char */ term->tio.c_cc[VTIME] = 0; /* No timer */ @@ -523,7 +530,11 @@ static void terminfo_input_deinit(TERM_REC *term) void terminfo_cont(TERM_REC *term) { if (term->TI_smcup) - tput(tparm(term->TI_smcup)); + tput(tparm(term->TI_smcup)); + + if (term->TI_smkx) + tput(tparm(term->TI_smkx)); + terminfo_input_init(term); } @@ -538,6 +549,9 @@ void terminfo_stop(TERM_REC *term) if (term->TI_rmcup) tput(tparm(term->TI_rmcup)); + if (term->TI_rmkx) + tput(tparm(term->TI_rmkx)); + /* reset input settings */ terminfo_input_deinit(term); fflush(term->out); @@ -646,11 +660,11 @@ static int term_setup(TERM_REC *term) str = g_string_new(NULL); if (term->TI_sgr0) g_string_append(str, term->TI_sgr0); - if (term->TI_rmul && (term->TI_sgr0 == NULL || strcmp(term->TI_rmul, term->TI_sgr0) != 0)) + if (term->TI_rmul && (term->TI_sgr0 == NULL || g_strcmp0(term->TI_rmul, term->TI_sgr0) != 0)) g_string_append(str, term->TI_rmul); - if (term->TI_rmso && (term->TI_sgr0 == NULL || strcmp(term->TI_rmso, term->TI_sgr0) != 0)) + if (term->TI_rmso && (term->TI_sgr0 == NULL || g_strcmp0(term->TI_rmso, term->TI_sgr0) != 0)) g_string_append(str, term->TI_rmso); - if (term->TI_ritm && (term->TI_sgr0 == NULL || strcmp(term->TI_ritm, term->TI_sgr0) != 0)) + if (term->TI_ritm && (term->TI_sgr0 == NULL || g_strcmp0(term->TI_ritm, term->TI_sgr0) != 0)) g_string_append(str, term->TI_ritm); term->TI_normal = str->str; g_string_free(str, FALSE); diff --git a/src/fe-text/terminfo-core.h b/src/fe-text/terminfo-core.h index 6ab4637d..21398791 100644 --- a/src/fe-text/terminfo-core.h +++ b/src/fe-text/terminfo-core.h @@ -88,6 +88,10 @@ struct _TERM_REC { /* Beep */ char *TI_bel; + + /* Keyboard-transmit mode */ + const char *TI_smkx; + const char *TI_rmkx; }; extern TERM_REC *current_term; diff --git a/src/fe-text/tparm.c b/src/fe-text/tparm.c index 3f58e6f3..97c790da 100644 --- a/src/fe-text/tparm.c +++ b/src/fe-text/tparm.c @@ -153,7 +153,7 @@ static int termcap; all terminfo codes are invalid unless something has been pushed on the stack and termcap strings will never push things on the stack (%p isn't used by termcap). So where we have a choice we make the - decision by wether or not somthing has been pushed on the stack. + decision by whether or not somthing has been pushed on the stack. The static variable termcap keeps track of this; it starts out set to 1 and is incremented as each argument processed by a termcap % code, however if something is pushed on the stack it's set to 0 and the @@ -170,7 +170,7 @@ static int termcap; %c output pop as a char %'c' push character constant c. %{n} push decimal constant n. - %p[1-9] push paramter [1-9] + %p[1-9] push parameter [1-9] %g[a-z] push variable [a-z] %P[a-z] put pop in variable [a-z] %l push the length of pop (a string) @@ -188,7 +188,7 @@ static int termcap; %O logical or pop and pop and push the result %! push the logical not of pop %? condition %t if_true [%e if_false] %; - if condtion evaulates as true then evaluate if_true, + if condition evaulates as true then evaluate if_true, else evaluate if_false. elseif's can be done: %? cond %t true [%e cond2 %t true2] ... [%e condN %t trueN] [%e false] %; %i add one to parameters 1 and 2. (ANSI) @@ -208,7 +208,7 @@ static int termcap; (UW) %sx subtract parameter FROM the character x %>xy if parameter > character x then add character y to parameter %B convert to BCD (parameter = (parameter/10)*16 + parameter%16) - %D Delta Data encode (parameter = parameter - 2*(paramter%16)) + %D Delta Data encode (parameter = parameter - 2*(parameter%16)) %i increment the first two parameters by one %n xor the first two parameters by 0140 (GNU) %m xor the first two parameters by 0177 @@ -216,7 +216,7 @@ static int termcap; (GNU) %b backup to previous parameter (GNU) %f skip this parameter - Note the two definitions of %a, the GNU defintion is used if the characters + Note the two definitions of %a, the GNU definition is used if the characters after the 'a' are valid, otherwise the UW definition is used. (GNU) used by GNU Emacs termcap libraries @@ -316,7 +316,7 @@ char *tparm(const char *str, ...) { if ((sp[1] == 'p' || sp[1] == 'c') && sp[2] != '\0' && fmt == NULL) { /* GNU aritmitic parameter, what they - realy need is terminfo. */ + really need is terminfo. */ int val, lc; if (sp[1] == 'p' && getarg(termcap - 1 + sp[2] - '@', |