Changeset 6a75c134 in mainline


Ignore:
Timestamp:
2016-03-08T09:21:14Z (8 years ago)
Author:
Aurelio Colosimo <aurelio@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a363016
Parents:
83b2e73
Message:

tab arguments completion: defined and handled hints_enum callback in cmd_info_t

Location:
kernel/generic
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/console/kconsole.h

    r83b2e73 r6a75c134  
    8888        /** Function for printing detailed help. */
    8989        void (* help)(void);
     90        /** Function for enumerating hints for arguments. */
     91        hints_enum_func_t hints_enum;
    9092} cmd_info_t;
    9193
  • kernel/generic/src/console/kconsole.c

    r83b2e73 r6a75c134  
    286286}
    287287
     288NO_TRACE static cmd_info_t *parse_cmd(const wchar_t *cmdline)
     289{
     290        size_t start = 0;
     291        size_t end;
     292        char *tmp;
     293       
     294        while (isspace(cmdline[start]))
     295                start++;
     296        end = start + 1;
     297        while (!isspace(cmdline[end]))
     298                end++;
     299       
     300        tmp = malloc(STR_BOUNDS(end - start + 1), 0);
     301       
     302        wstr_to_str(tmp, end - start + 1, &cmdline[start]);
     303       
     304        spinlock_lock(&cmd_lock);
     305       
     306        list_foreach(cmd_list, link, cmd_info_t, hlp) {
     307                spinlock_lock(&hlp->lock);
     308               
     309                if (str_cmp(hlp->name, tmp) == 0) {
     310                        spinlock_unlock(&hlp->lock);
     311                        spinlock_unlock(&cmd_lock);
     312                        free(tmp);
     313                        return hlp;
     314                }
     315               
     316                spinlock_unlock(&hlp->lock);
     317        }
     318       
     319        free(tmp);
     320        spinlock_unlock(&cmd_lock);
     321       
     322        return NULL;
     323}
     324
    288325NO_TRACE static wchar_t *clever_readline(const char *prompt, indev_t *indev)
    289326{
     
    345382                        if (beg == 0) {
    346383                                /* Command completion */
    347                                 found = cmdtab_compl(tmp, STR_BOUNDS(MAX_CMDLINE), indev, cmdtab_enum);
     384                                found = cmdtab_compl(tmp, STR_BOUNDS(MAX_CMDLINE), indev,
     385                                    cmdtab_enum);
    348386                        } else {
    349                                 /* Symbol completion */
    350                                 found = symtab_compl(tmp, STR_BOUNDS(MAX_CMDLINE), indev);
     387                                /* Arguments completion */
     388                                cmd_info_t *cmd = parse_cmd(current);
     389                                if (!cmd || !cmd->hints_enum)
     390                                        continue;
     391                                found = cmdtab_compl(tmp, STR_BOUNDS(MAX_CMDLINE), indev,
     392                                    cmd->hints_enum);
    351393                        }
    352394                       
Note: See TracChangeset for help on using the changeset viewer.