From: David Lawrence Ramsey Date: Fri, 25 Feb 2005 19:17:57 +0000 (+0000) Subject: start adding multibyte/wide character support to the help browser code X-Git-Tag: v1.3.6~76 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=b6e79fddafd6a33cf8f54f5406dbb19dca3a90b2;p=nano.git start adding multibyte/wide character support to the help browser code git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2327 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/ChangeLog b/ChangeLog index 26551145..350ee50e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -140,7 +140,7 @@ CVS code - supposed to return void anyway. Also, the value of RETSIGTYPE is sometimes misdetected as int, leading to compilation warnings or errors. Changes to cancel_fork(), - handle_hipterm(), do_suspend(), and do_cont(). (David + handle_hupterm(), do_suspend(), and do_cont(). (David Benbennick) - Change flags to an unsigned long, and totsize to a size_t. (DLR) @@ -161,6 +161,8 @@ CVS code - routine to get the current user's home directory into the new function get_homedir(), and use it where necessary. Also add a few miscellaneous tweaks. + - Still more steps toward multibyte/wide character support. + Changes to help_init(). (DLR) - cut.c: do_cut_text() - If keep_cutbuffer is FALSE, only blow away the text in the diff --git a/src/nano.c b/src/nano.c index 254ce266..c490a3aa 100644 --- a/src/nano.c +++ b/src/nano.c @@ -270,6 +270,11 @@ void help_init(void) const shortcut *s; #ifndef NANO_SMALL const toggle *t; +#ifdef ENABLE_NANORC + bool old_whitespace = ISSET(WHITESPACE_DISPLAY); + + UNSET(WHITESPACE_DISPLAY); +#endif #endif /* First, set up the initial help text for the current function. */ @@ -394,10 +399,10 @@ void help_init(void) * Each line has "M-%c\t\t\t", which fills 24 columns, plus a space, * plus translated text, plus '\n'. */ if (currshortcut == main_list) { - size_t endislen = strlen(_("enable/disable")); + size_t endis_len = strlen(_("enable/disable")); for (t = toggles; t != NULL; t = t->next) - allocsize += 8 + strlen(t->desc) + endislen; + allocsize += 8 + strlen(t->desc) + endis_len; } #endif @@ -424,13 +429,22 @@ void help_init(void) if (s->ctrlval != NANO_NO_KEY) { entries++; #ifndef NANO_SMALL - if (s->ctrlval == NANO_HISTORY_KEY) - ptr += sprintf(ptr, "%.7s", _("Up")); - else + if (s->ctrlval == NANO_HISTORY_KEY) { + char *up_ptr = display_string(_("Up"), 0, 7, FALSE); + + ptr += sprintf(ptr, "%s", up_ptr); + + free(up_ptr); + } else #endif - if (s->ctrlval == NANO_CONTROL_SPACE) - ptr += sprintf(ptr, "^%.6s", _("Space")); - else if (s->ctrlval == NANO_CONTROL_8) + if (s->ctrlval == NANO_CONTROL_SPACE) { + char *space_ptr = display_string(_("Space"), 0, 6, + FALSE); + + ptr += sprintf(ptr, "^%s", space_ptr); + + free(space_ptr); + } else if (s->ctrlval == NANO_CONTROL_8) ptr += sprintf(ptr, "^?"); else ptr += sprintf(ptr, "^%c", s->ctrlval + 64); @@ -459,9 +473,14 @@ void help_init(void) } /* If the primary meta key sequence is the first entry, * don't put parentheses around it. */ - if (entries == 1 && s->metaval == NANO_ALT_SPACE) - ptr += sprintf(ptr, "M-%.5s", _("Space")); - else + if (entries == 1 && s->metaval == NANO_ALT_SPACE) { + char *space_ptr = display_string(_("Space"), 0, 5, + FALSE); + + ptr += sprintf(ptr, "M-%s", space_ptr); + + free(space_ptr); + } else ptr += sprintf(ptr, entries == 1 ? "M-%c" : "(M-%c)", toupper(s->metaval)); *(ptr++) = '\t'; @@ -486,7 +505,16 @@ void help_init(void) } assert(s->help != NULL); - ptr += sprintf(ptr, "%.*s\n", COLS > 24 ? COLS - 24 : 0, s->help); + + if (COLS > 24) { + char *help_ptr = display_string(s->help, 0, COLS - 24, + FALSE); + + ptr += sprintf(ptr, help_ptr); + + free(help_ptr); + } + ptr += sprintf(ptr, "\n"); } #ifndef NANO_SMALL @@ -498,7 +526,12 @@ void help_init(void) t->desc, _("enable/disable")); } } -#endif /* !NANO_SMALL */ + +#ifdef ENABLE_NANORC + if (old_whitespace) + SET(WHITESPACE_DISPLAY); +#endif +#endif /* If all went well, we didn't overwrite the allocated space for * help_text. */