Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/console/kconsole.c

    r583c2a3 r690ad20  
    3939 */
    4040
     41#include <adt/list.h>
     42#include <arch.h>
    4143#include <assert.h>
    42 #include <console/kconsole.h>
    43 #include <console/console.h>
    4444#include <console/chardev.h>
    4545#include <console/cmd.h>
     46#include <console/console.h>
     47#include <console/kconsole.h>
    4648#include <console/prompt.h>
     49#include <debug.h>
     50#include <errno.h>
     51#include <halt.h>
     52#include <macros.h>
     53#include <panic.h>
    4754#include <stdio.h>
    48 #include <panic.h>
     55#include <stdlib.h>
     56#include <str.h>
     57#include <symtab.h>
     58#include <sysinfo/sysinfo.h>
    4959#include <typedefs.h>
    50 #include <adt/list.h>
    51 #include <arch.h>
    52 #include <macros.h>
    53 #include <debug.h>
    54 #include <halt.h>
    55 #include <str.h>
    56 #include <sysinfo/sysinfo.h>
    57 #include <symtab.h>
    58 #include <errno.h>
    59 #include <putchar.h>
    60 #include <stdlib.h>
    6160
    6261/** Simple kernel console.
     
    8584SPINLOCK_INITIALIZE(cmd_lock);  /**< Lock protecting command list. */
    8685LIST_INITIALIZE(cmd_list);      /**< Command list. */
     86
     87#define MAX_SYMBOL_NAME 64
    8788
    8889static char32_t history[KCONSOLE_HISTORY][MAX_CMDLINE] = { };
     
    156157
    157158/** Print count times a character */
    158 _NO_TRACE static void print_cc(char32_t ch, size_t count)
    159 {
    160         size_t i;
    161         for (i = 0; i < count; i++)
    162                 putuchar(ch);
     159_NO_TRACE static void print_cc(char ch, size_t count)
     160{
     161        // FIXME: only lock once
     162
     163        for (size_t i = 0; i < count; i++)
     164                putstr(&ch, 1);
    163165}
    164166
     
    345347                if (ch == '\n') {
    346348                        /* Enter */
    347                         putuchar(ch);
     349                        putstr("\n", 1);
    348350                        break;
    349351                }
     
    356358                        if (wstr_remove(current, position - 1)) {
    357359                                position--;
    358                                 putuchar('\b');
     360                                putstr("\b", 1);
    359361                                printf("%ls ", current + position);
    360362                                print_cc('\b', wstr_length(current) - position + 1);
     
    366368                        /* Tab completion */
    367369
    368                         /* Move to the end of the word */
    369                         for (; (current[position] != 0) && (!isspace(current[position]));
    370                             position++)
    371                                 putuchar(current[position]);
     370                        size_t i = position;
     371                        while (current[i] && !isspace(current[i]))
     372                                i++;
     373
     374                        char32_t stash = current[i];
     375                        current[i] = 0;
     376                        printf("%ls", &current[position]);
     377                        current[i] = stash;
     378                        position = i;
    372379
    373380                        /*
     
    428435                         */
    429436                        size_t off = 0;
    430                         size_t i = 0;
    431                         while ((ch = str_decode(tmp, &off, STR_NO_LIMIT)) != 0) {
     437                        for (size_t i = 0; (ch = str_decode(tmp, &off, STR_NO_LIMIT)); i++)
    432438                                if (!wstr_linsert(current, ch, position + i, MAX_CMDLINE))
    433439                                        break;
    434 
    435                                 i++;
    436                         }
    437440
    438441                        if (found > 1) {
     
    464467                        /* Left */
    465468                        if (position > 0) {
    466                                 putuchar('\b');
     469                                putstr("\b", 1);
    467470                                position--;
    468471                        }
     
    473476                        /* Right */
    474477                        if (position < wstr_length(current)) {
    475                                 putuchar(current[position]);
     478                                printf("%lc", current[position]);
    476479                                position++;
    477480                        }
     
    597600                /* It's a number - convert it */
    598601                uint64_t value;
    599                 char *end;
     602                const char *end;
    600603                errno_t rc = str_uint64_t(text, &end, 0, false, &value);
    601604                if (end != text + len)
Note: See TracChangeset for help on using the changeset viewer.