Changes in uspace/lib/clui/tinput.h [79ae36dd:9be9c4d] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/clui/tinput.h
r79ae36dd r9be9c4d 1 1 /* 2 * Copyright (c) 201 0Jiri Svoboda2 * Copyright (c) 2011 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 37 37 #define LIBCLUI_TINPUT_H_ 38 38 39 #include < stdio.h>39 #include <adt/list.h> 40 40 #include <async.h> 41 41 #include <inttypes.h> 42 42 #include <io/console.h> 43 #include <stdio.h> 43 44 44 45 #define HISTORY_LEN 10 45 46 #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; 46 100 47 101 /** Text input field (command line). … … 53 107 console_ctrl_t *console; 54 108 109 /** Prompt string */ 110 char *prompt; 111 112 /** Completion ops. */ 113 tinput_compl_ops_t *compl_ops; 114 55 115 /** Buffer holding text currently being edited */ 56 116 wchar_t buffer[INPUT_MAX_SIZE + 1]; 57 117 58 /** Screen coordinates of the top-left corner of the text field */ 59 sysarg_t col0; 60 sysarg_t row0; 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; 61 122 62 123 /** Screen dimensions */ … … 90 151 91 152 extern 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 *); 92 155 extern void tinput_destroy(tinput_t *); 93 156 extern int tinput_read(tinput_t *, char **);
Note:
See TracChangeset
for help on using the changeset viewer.