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
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/generic/src/console/kconsole.c

    r2398ee9 rc8bf88d  
    260260                       
    261261                        if (wstr_remove(current, position - 1)) {
     262                                position--;
    262263                                putchar('\b');
    263                                 printf("%ls", current + position);
    264                                 position--;
    265                                 print_cc('\b', wstr_length(current) - position);
     264                                printf("%ls ", current + position);
     265                                print_cc('\b', wstr_length(current) - position + 1);
    266266                                continue;
    267267                        }
     
    334334                }
    335335               
    336                 if (ch == 0x1b) {
    337                         /* Special command */
    338                         wchar_t mod = _getc(indev);
    339                         wchar_t ch = _getc(indev);
    340                        
    341                         if ((mod != 0x5b) && (mod != 0x4f))
     336                if (ch == U_LEFT_ARROW) {
     337                        /* Left */
     338                        if (position > 0) {
     339                                putchar('\b');
     340                                position--;
     341                        }
     342                        continue;
     343                }
     344               
     345                if (ch == U_RIGHT_ARROW) {
     346                        /* Right */
     347                        if (position < wstr_length(current)) {
     348                                putchar(current[position]);
     349                                position++;
     350                        }
     351                        continue;
     352                }
     353               
     354                if ((ch == U_UP_ARROW) || (ch == U_DOWN_ARROW)) {
     355                        /* Up, down */
     356                        print_cc('\b', position);
     357                        print_cc(' ', wstr_length(current));
     358                        print_cc('\b', wstr_length(current));
     359                       
     360                        if (ch == U_UP_ARROW) {
     361                                /* Up */
     362                                if (history_pos == 0)
     363                                        history_pos = KCONSOLE_HISTORY - 1;
     364                                else
     365                                        history_pos--;
     366                        } else {
     367                                /* Down */
     368                                history_pos++;
     369                                history_pos = history_pos % KCONSOLE_HISTORY;
     370                        }
     371                        current = history[history_pos];
     372                        printf("%ls", current);
     373                        position = wstr_length(current);
     374                        continue;
     375                }
     376               
     377                if (ch == U_HOME_ARROW) {
     378                        /* Home */
     379                        print_cc('\b', position);
     380                        position = 0;
     381                        continue;
     382                }
     383               
     384                if (ch == U_END_ARROW) {
     385                        /* End */
     386                        printf("%ls", current + position);
     387                        position = wstr_length(current);
     388                        continue;
     389                }
     390               
     391                if (ch == U_DELETE) {
     392                        /* Delete */
     393                        if (position == wstr_length(current))
    342394                                continue;
    343395                       
    344                         if ((ch == 0x33) && (_getc(indev) == 0x7e)) {
    345                                 /* Delete */
    346                                 if (position == wstr_length(current))
    347                                         continue;
    348                                
    349                                 if (wstr_remove(current, position)) {
    350                                         putchar('\b');
    351                                         printf("%ls", current + position);
    352                                         position--;
    353                                         print_cc('\b', wstr_length(current) - position);
    354                                 }
    355                         } else if (ch == 0x48) {
    356                                 /* Home */
    357                                 print_cc('\b', position);
    358                                 position = 0;
    359                         } else if (ch == 0x46) {
    360                                 /* End */
    361                                 printf("%ls", current + position);
    362                                 position = wstr_length(current);
    363                         } else if (ch == 0x44) {
    364                                 /* Left */
    365                                 if (position > 0) {
    366                                         putchar('\b');
    367                                         position--;
    368                                 }
    369                         } else if (ch == 0x43) {
    370                                 /* Right */
    371                                 if (position < wstr_length(current)) {
    372                                         putchar(current[position]);
    373                                         position++;
    374                                 }
    375                         } else if ((ch == 0x41) || (ch == 0x42)) {
    376                                 /* Up, down */
    377                                 print_cc('\b', position);
    378                                 print_cc(' ', wstr_length(current));
    379                                 print_cc('\b', wstr_length(current));
    380                                
    381                                 if (ch == 0x41) {
    382                                         /* Up */
    383                                         if (history_pos == 0)
    384                                                 history_pos = KCONSOLE_HISTORY - 1;
    385                                         else
    386                                                 history_pos--;
    387                                 } else {
    388                                         /* Down */
    389                                         history_pos++;
    390                                         history_pos = history_pos % KCONSOLE_HISTORY;
    391                                 }
    392                                 current = history[history_pos];
    393                                 printf("%ls", current);
    394                                 position = wstr_length(current);
     396                        if (wstr_remove(current, position)) {
     397                                printf("%ls ", current + position);
     398                                print_cc('\b', wstr_length(current) - position + 1);
    395399                        }
    396400                        continue;
Note: See TracChangeset for help on using the changeset viewer.