Changeset c8bf88d in mainline for kernel/genarch/src/srln/srln.c


Ignore:
Timestamp:
2009-04-03T15:52:14Z (15 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a7b1071
Parents:
2398ee9
Message:

represent special keystrokes (cursor arrows, page up/down, delete, etc.) as appropriate Unicode characters
do not parse ANSI control sequences in kconsole, but in serial line driver

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/genarch/src/srln/srln.c

    r2398ee9 rc8bf88d  
    4040#include <proc/thread.h>
    4141#include <arch.h>
     42#include <string.h>
    4243
    4344static indev_t srlnout;
     
    5152        indev_t *in = (indev_t *) arg;
    5253        bool cr = false;
     54        uint32_t escape = 0;
    5355       
    5456        while (true) {
    55                 uint8_t ch = _getc(in);
     57                wchar_t ch = _getc(in);
    5658               
     59                /* ANSI escape sequence processing */
     60                if (escape != 0) {
     61                        escape <<= 8;
     62                        escape |= ch & 0xff;
     63                       
     64                        if ((escape == 0x1b4f) || (escape == 0x1b5b) || (escape == 0x1b5b33))
     65                                continue;
     66                       
     67                        switch (escape) {
     68                        case 0x1b4f46:
     69                        case 0x1b5b46:
     70                                ch = U_END_ARROW;
     71                                escape = 0;
     72                                break;
     73                        case 0x1b4f48:
     74                        case 0x1b5b48:
     75                                ch = U_HOME_ARROW;
     76                                escape = 0;
     77                                break;
     78                        case 0x1b5b41:
     79                                ch = U_UP_ARROW;
     80                                escape = 0;
     81                                break;
     82                        case 0x1b5b42:
     83                                ch = U_DOWN_ARROW;
     84                                escape = 0;
     85                                break;
     86                        case 0x1b5b43:
     87                                ch = U_RIGHT_ARROW;
     88                                escape = 0;
     89                                break;
     90                        case 0x1b5b44:
     91                                ch = U_LEFT_ARROW;
     92                                escape = 0;
     93                                break;
     94                        case 0x1b5b337e:
     95                                ch = U_DELETE;
     96                                escape = 0;
     97                                break;
     98                        default:
     99                                escape = 0;
     100                        }
     101                }
     102               
     103                if (ch == 0x1b) {
     104                        escape = ch & 0xff;
     105                        continue;
     106                }
     107               
     108                /* Replace carriage return with line feed
     109                   and suppress any following line feed */
    57110                if ((ch == '\n') && (cr)) {
    58111                        cr = false;
     
    66119                        cr = false;
    67120               
     121                /* Backspace */
    68122                if (ch == 0x7f)
    69123                        ch = '\b';
Note: See TracChangeset for help on using the changeset viewer.