#include <curses.h>
#include <gpxe/editstring.h>
Go to the source code of this file.
Data Structures | |
| struct | edit_box |
| An editable text box widget. More... | |
Enumerations | |
| enum | edit_box_flags { EDITBOX_STARS = 0x0001 } |
| Editable text box widget flags. More... | |
Functions | |
| FILE_LICENCE (GPL2_OR_LATER) | |
| void | init_editbox (struct edit_box *box, char *buf, size_t len, WINDOW *win, unsigned int row, unsigned int col, unsigned int width, unsigned int flags) __attribute__((nonnull(1 |
| void void | draw_editbox (struct edit_box *box) __nonnull |
| Draw text box widget. | |
| static int | edit_editbox (struct edit_box *box, int key) |
| Edit text box widget. | |
Definition in file editbox.h.
| enum edit_box_flags |
Editable text box widget flags.
Definition at line 34 of file editbox.h.
00034 { 00035 /** Show stars instead of contents (for password widgets) */ 00036 EDITBOX_STARS = 0x0001, 00037 };
| FILE_LICENCE | ( | GPL2_OR_LATER | ) |
| void init_editbox | ( | struct edit_box * | box, | |
| char * | buf, | |||
| size_t | len, | |||
| WINDOW * | win, | |||
| unsigned int | row, | |||
| unsigned int | col, | |||
| unsigned int | width, | |||
| unsigned int | flags | |||
| ) |
| void void draw_editbox | ( | struct edit_box * | box | ) |
Draw text box widget.
| box | Editable text box widget |
Definition at line 65 of file editbox.c.
References edit_string::buf, edit_box::col, edit_string::cursor, EDITBOX_MIN_CHARS, EDITBOX_STARS, edit_box::first, edit_box::flags, memcpy, memset(), mvwprintw, edit_box::row, stdscr, edit_box::string, strlen(), edit_box::width, edit_box::win, and wmove().
Referenced by draw_setting(), and login_ui().
00065 { 00066 size_t width = box->width; 00067 char buf[ width + 1 ]; 00068 signed int cursor_offset, underflow, overflow, first; 00069 size_t len; 00070 00071 /* Adjust starting offset so that cursor remains within box */ 00072 cursor_offset = ( box->string.cursor - box->first ); 00073 underflow = ( EDITBOX_MIN_CHARS - cursor_offset ); 00074 overflow = ( cursor_offset - ( width - 1 ) ); 00075 first = box->first; 00076 if ( underflow > 0 ) { 00077 first -= underflow; 00078 if ( first < 0 ) 00079 first = 0; 00080 } else if ( overflow > 0 ) { 00081 first += overflow; 00082 } 00083 box->first = first; 00084 cursor_offset = ( box->string.cursor - first ); 00085 00086 /* Construct underscore-padded string portion */ 00087 memset ( buf, '_', width ); 00088 buf[width] = '\0'; 00089 len = ( strlen ( box->string.buf ) - first ); 00090 if ( len > width ) 00091 len = width; 00092 if ( box->flags & EDITBOX_STARS ) { 00093 memset ( buf, '*', len ); 00094 } else { 00095 memcpy ( buf, ( box->string.buf + first ), len ); 00096 } 00097 00098 /* Print box content and move cursor */ 00099 if ( ! box->win ) 00100 box->win = stdscr; 00101 mvwprintw ( box->win, box->row, box->col, "%s", buf ); 00102 wmove ( box->win, box->row, ( box->col + cursor_offset ) ); 00103 }
| static int edit_editbox | ( | struct edit_box * | box, | |
| int | key | |||
| ) | [inline, static] |
Edit text box widget.
| box | Editable text box widget | |
| key | Key pressed by user |
| key | Key returned to application, or zero |
Definition at line 57 of file editbox.h.
References edit_string(), and edit_box::string.
Referenced by edit_setting(), and login_ui().
00057 { 00058 return edit_string ( &box->string, key ); 00059 }
1.5.7.1