Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/clui/tinput.h

    r9be9c4d r79ae36dd  
    11/*
    2  * Copyright (c) 2011 Jiri Svoboda
     2 * Copyright (c) 2010 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    3737#define LIBCLUI_TINPUT_H_
    3838
    39 #include <adt/list.h>
     39#include <stdio.h>
    4040#include <async.h>
    4141#include <inttypes.h>
    4242#include <io/console.h>
    43 #include <stdio.h>
    4443
    4544#define HISTORY_LEN     10
    4645#define INPUT_MAX_SIZE  1024
    47 
    48 /** Begin enumeration of text completions.
    49  *
    50  * When user requests text completion, tinput will call this function to start
    51  * text completion operation. @a *cstart should be set to the position
    52  * (character index) of the first character of the 'word' that is being
    53  * completed. The resulting text is obtained by replacing the range of text
    54  * starting at @a *cstart and ending at @a pos with the completion text.
    55  *
    56  * The function can pass information to the get_next and fini functions
    57  * via @a state. The init function allocates the state object and stores
    58  * a pointer to it to @a *state. The fini function destroys the state object.
    59  *
    60  * @param text          Current contents of edit buffer (null-terminated).
    61  * @param pos           Current caret position.
    62  * @param cstart        Output, position in text where completion begins from.
    63  * @param state         Output, pointer to a client state object.
    64  *
    65  * @return              EOK on success, negative error code on failure.
    66  */
    67 typedef int (*tinput_compl_init_fn)(wchar_t *text, size_t pos, size_t *cstart,
    68     void **state);
    69 
    70 /** Obtain one text completion alternative.
    71  *
    72  * Upon success the function sets @a *compl to point to a string, the
    73  * completion text. The caller (Tinput) should not modify or free the text.
    74  * The pointer is only valid until the next invocation of any completion
    75  * function.
    76  *
    77  * @param state         Pointer to state object created by the init funtion.
    78  * @param compl         Output, the completion text, ownership retained.
    79  *
    80  * @return              EOK on success, negative error code on failure.
    81  */
    82 typedef int (*tinput_compl_get_next_fn)(void *state, char **compl);
    83 
    84 
    85 /** Finish enumeration of text completions.
    86  *
    87  * The function must deallocate any state information allocated by the init
    88  * function or temporary data allocated by the get_next function.
    89  *
    90  * @param state         Pointer to state object created by the init funtion.
    91  */
    92 typedef void (*tinput_compl_fini_fn)(void *state);
    93 
    94 /** Text completion ops. */
    95 typedef struct {
    96         tinput_compl_init_fn init;
    97         tinput_compl_get_next_fn get_next;
    98         tinput_compl_fini_fn fini;
    99 } tinput_compl_ops_t;
    10046
    10147/** Text input field (command line).
     
    10753        console_ctrl_t *console;
    10854       
    109         /** Prompt string */
    110         char *prompt;
    111        
    112         /** Completion ops. */
    113         tinput_compl_ops_t *compl_ops;
    114        
    11555        /** Buffer holding text currently being edited */
    11656        wchar_t buffer[INPUT_MAX_SIZE + 1];
    11757       
    118         /** Linear position on screen where the prompt starts */
    119         unsigned prompt_coord;
    120         /** Linear position on screen where the text field starts */
    121         unsigned text_coord;
     58        /** Screen coordinates of the top-left corner of the text field */
     59        sysarg_t col0;
     60        sysarg_t row0;
    12261       
    12362        /** Screen dimensions */
     
    15190
    15291extern tinput_t *tinput_new(void);
    153 extern int tinput_set_prompt(tinput_t *, const char *);
    154 extern void tinput_set_compl_ops(tinput_t *, tinput_compl_ops_t *);
    15592extern void tinput_destroy(tinput_t *);
    15693extern int tinput_read(tinput_t *, char **);
Note: See TracChangeset for help on using the changeset viewer.