Changes in uspace/lib/clui/tinput.h [9be9c4d:79ae36dd] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/clui/tinput.h
r9be9c4d r79ae36dd 1 1 /* 2 * Copyright (c) 201 1Jiri Svoboda2 * Copyright (c) 2010 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 37 37 #define LIBCLUI_TINPUT_H_ 38 38 39 #include < adt/list.h>39 #include <stdio.h> 40 40 #include <async.h> 41 41 #include <inttypes.h> 42 42 #include <io/console.h> 43 #include <stdio.h>44 43 45 44 #define HISTORY_LEN 10 46 45 #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 start51 * text completion operation. @a *cstart should be set to the position52 * (character index) of the first character of the 'word' that is being53 * completed. The resulting text is obtained by replacing the range of text54 * 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 functions57 * via @a state. The init function allocates the state object and stores58 * 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, the73 * completion text. The caller (Tinput) should not modify or free the text.74 * The pointer is only valid until the next invocation of any completion75 * 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 init88 * 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;100 46 101 47 /** Text input field (command line). … … 107 53 console_ctrl_t *console; 108 54 109 /** Prompt string */110 char *prompt;111 112 /** Completion ops. */113 tinput_compl_ops_t *compl_ops;114 115 55 /** Buffer holding text currently being edited */ 116 56 wchar_t buffer[INPUT_MAX_SIZE + 1]; 117 57 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; 122 61 123 62 /** Screen dimensions */ … … 151 90 152 91 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 *);155 92 extern void tinput_destroy(tinput_t *); 156 93 extern int tinput_read(tinput_t *, char **);
Note:
See TracChangeset
for help on using the changeset viewer.