Changeset 6071a8f in mainline for uspace/app/bdsh/input.c


Ignore:
Timestamp:
2009-04-07T19:03:18Z (15 years ago)
Author:
Jiri Svoboda <jirik.svoboda@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9eb3623
Parents:
2845930
Message:

Read UCS chars in bdsh and encode them. (bdsh is still largely ignorant of UCS but it will work somehow with the characters now).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bdsh/input.c

    r2845930 r6071a8f  
    3737#include <kbd/kbd.h>
    3838#include <kbd/keycode.h>
     39#include <errno.h>
     40#include <bool.h>
    3941
    4042#include "config.h"
     
    100102{
    101103        kbd_event_t ev;
    102         int chars;
     104        size_t offs, otmp;
     105        wchar_t dec;
    103106
    104         chars = 0;
    105         while (chars < n - 1) {
     107        offs = 0;
     108        while (true) {
    106109                fflush(stdout);
    107110                if (kbd_get_event(&ev) < 0)
     
    113116                        break;
    114117                if (ev.key == KC_BACKSPACE) {
    115                         if (chars > 0) {
     118                        if (offs > 0) {
     119                                /*
     120                                 * Back up until we reach valid start of
     121                                 * character.
     122                                 */
     123                                while (offs > 0) {
     124                                        --offs; otmp = offs;
     125                                        dec = str_decode(buffer, &otmp, n);
     126                                        if (dec != U_SPECIAL)
     127                                                break;
     128                                }
    116129                                putchar('\b');
    117                                 --chars;
    118130                        }
    119131                        continue;
     
    121133                if (ev.c >= ' ') {
    122134                        //putchar(ev.c);
    123                         console_putchar(ev.c);
    124                         buffer[chars++] = ev.c;
     135                        if (chr_encode(ev.c, buffer, &offs, n - 1) == EOK)
     136                                console_putchar(ev.c);
    125137                }
    126138        }
    127139        putchar('\n');
    128         buffer[chars] = '\0';
     140        buffer[offs] = '\0';
    129141}
    130142
Note: See TracChangeset for help on using the changeset viewer.