summaryrefslogtreecommitdiff
path: root/console
diff options
context:
space:
mode:
authorJeremie Koenig <jk@jk.fr.eu.org>2010-08-01 13:52:04 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2010-08-01 14:02:43 +0200
commit45e3044ed47fcaab15579da516df8922b3b48954 (patch)
tree7e0c4ca4d49afba73218f8fd51c40cce52eae996 /console
parentee096c09818baf60ef2f8bafc421171ceadd8e18 (diff)
Add wide character support to the Hurd console
* hurd/console.h (CONS_WCHAR_MASK, CONS_WCHAR_CONTINUED): New macros. * console/console.c: Include <locale.h> (main): Call setlocale. * console/display.c (display_output_one): Call wcwidth() to know the width of the character to be displayed. Iterate over this with to insert characters with the additional CONS_WCHAR_CONTINUED flag. Update screen_shift_right and display_record_filechange calls accordingly. * console-client/vga-dynafont.c (WCHAR_BOLD, WCHAR_ITALIC, WCHAR_MASK): Change macro values. (dynafont_new): Use glyph->bbox.{width,height} instead of df->font->bbox.{width,height}. (dynafont_change_font): Likewise. (dynafont_lookup_internal): Likewise. Mask out CONS_WCHAR_CONTINUED before calling bdf_find_glyph, but test it for the second position of a double-width glyph. (dynafont_activate): Enable 9-bit width only when font width is not dividable by 8.
Diffstat (limited to 'console')
-rw-r--r--console/console.c3
-rw-r--r--console/display.c29
2 files changed, 25 insertions, 7 deletions
diff --git a/console/console.c b/console/console.c
index 6225d71d..eb2f1f44 100644
--- a/console/console.c
+++ b/console/console.c
@@ -23,6 +23,7 @@
#include <stdlib.h>
#include <stddef.h>
#include <unistd.h>
+#include <locale.h>
#include <argp.h>
#include <argz.h>
@@ -2018,6 +2019,8 @@ main (int argc, char **argv)
/* Parse our command line arguments. */
argp_parse (&netfs_std_runtime_argp, argc, argv, 0, 0, cons);
+ setlocale (LC_CTYPE, "C.UTF-8");
+
task_get_bootstrap_port (mach_task_self (), &bootstrap);
netfs_init ();
diff --git a/console/display.c b/console/display.c
index 090aaf80..f6a24a8a 100644
--- a/console/display.c
+++ b/console/display.c
@@ -1593,23 +1593,38 @@ display_output_one (display_t display, wchar_t chr)
int line = (user->screen.cur_line + user->cursor.row)
% user->screen.lines;
int idx = line * user->screen.width + user->cursor.col;
+ int width, i;
+
+ width = wcwidth (chr);
+ if (width < 0)
+ width = 1;
if (display->insert_mode
- && user->cursor.col != user->screen.width - 1)
+ && user->cursor.col < user->screen.width - width)
{
/* If in insert mode, do the same as <ich1>. */
screen_shift_right (display, user->cursor.col,
user->cursor.row,
user->screen.width - 1, user->cursor.row,
- 1, L' ', display->attr.current);
+ width, L' ', display->attr.current);
+ }
+
+ if (display->attr.altchar)
+ chr = altchar_to_ucs4 (chr);
+
+ for (i = 0; i < width; i++)
+ {
+ if (user->cursor.col >= user->screen.width)
+ break;
+ user->_matrix[idx+i].chr = chr;
+ user->_matrix[idx+i].attr = display->attr.current;
+ user->cursor.col++;
+ chr |= CONS_WCHAR_CONTINUED;
}
- user->_matrix[idx].chr = display->attr.altchar
- ? altchar_to_ucs4 (chr) : chr;
- user->_matrix[idx].attr = display->attr.current;
+ if (i > 0)
+ display_record_filechange (display, idx, idx + i - 1);
- display_record_filechange (display, idx, idx);
- user->cursor.col++;
if (user->cursor.col == user->screen.width)
{
user->cursor.col = 0;