iPXE
settings_ui.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006 Michael Brown <mbrown@fensystems.co.uk>.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of the
7  * License, or any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  * 02110-1301, USA.
18  *
19  * You can also choose to distribute this program under the terms of
20  * the Unmodified Binary Distribution Licence (as given in the file
21  * COPYING.UBDL), provided that you have satisfied its requirements.
22  */
23 
24 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
25 
26 #include <stdio.h>
27 #include <stdarg.h>
28 #include <stdlib.h>
29 #include <unistd.h>
30 #include <string.h>
31 #include <curses.h>
32 #include <ipxe/console.h>
33 #include <ipxe/settings.h>
34 #include <ipxe/editbox.h>
35 #include <ipxe/keys.h>
36 #include <ipxe/ansicol.h>
37 #include <ipxe/jumpscroll.h>
38 #include <ipxe/settings_ui.h>
39 #include <config/branding.h>
40 
41 /** @file
42  *
43  * Option configuration console
44  *
45  */
46 
47 /* Screen layout */
48 #define TITLE_ROW 1U
49 #define SETTINGS_LIST_ROW 3U
50 #define SETTINGS_LIST_COL 1U
51 #define SETTINGS_LIST_ROWS ( LINES - 6U - SETTINGS_LIST_ROW )
52 #define INFO_ROW ( LINES - 5U )
53 #define ALERT_ROW ( LINES - 2U )
54 #define INSTRUCTION_ROW ( LINES - 2U )
55 #define INSTRUCTION_PAD " "
56 
57 /** Layout of text within a setting row */
58 #define SETTING_ROW_TEXT( cols ) struct { \
59  char start[0]; \
60  char pad1[1]; \
61  union { \
62  struct { \
63  char name[ cols - 1 - 1 - 1 - 1 - 1 ]; \
64  char pad2[1]; \
65  } __attribute__ (( packed )) settings; \
66  struct { \
67  char name[15]; \
68  char pad2[1]; \
69  char value[ cols - 1 - 15 - 1 - 1 - 1 - 1 ]; \
70  } __attribute__ (( packed )) setting; \
71  } u; \
72  char pad3[1]; \
73  char nul; \
74 } __attribute__ (( packed ))
75 
76 /** A settings user interface row */
78  /** Target configuration settings block
79  *
80  * Valid only for rows that lead to new settings blocks.
81  */
82  struct settings *settings;
83  /** Configuration setting origin
84  *
85  * Valid only for rows that represent individual settings.
86  */
87  struct settings *origin;
88  /** Configuration setting
89  *
90  * Valid only for rows that represent individual settings.
91  */
92  struct setting setting;
93  /** Screen row */
94  unsigned int row;
95  /** Edit box widget used for editing setting */
96  struct edit_box editbox;
97  /** Editing in progress flag */
98  int editing;
99  /** Dynamically allocated buffer for setting's value */
100  char *buf;
101 };
102 
103 /** A settings user interface */
104 struct settings_ui {
105  /** Settings block */
107  /** Jump scroller */
109  /** Current row */
111 };
112 
113 /**
114  * Select a setting
115  *
116  * @v ui Settings user interface
117  * @v index Index of setting row
118  * @ret count Number of setting rows
119  */
120 static unsigned int select_setting_row ( struct settings_ui *ui,
121  unsigned int index ) {
122  SETTING_ROW_TEXT ( COLS ) *text;
123  struct settings *settings;
124  struct setting *setting;
125  struct setting *previous = NULL;
126  unsigned int count = 0;
127 
128  /* Free any previous setting value */
129  free ( ui->row.buf );
130  ui->row.buf = NULL;
131 
132  /* Initialise structure */
133  memset ( &ui->row, 0, sizeof ( ui->row ) );
134  ui->row.row = ( SETTINGS_LIST_ROW + index - ui->scroll.first );
135 
136  /* Include parent settings block, if applicable */
137  if ( ui->settings->parent && ( count++ == index ) )
138  ui->row.settings = ui->settings->parent;
139 
140  /* Include any child settings blocks, if applicable */
141  list_for_each_entry ( settings, &ui->settings->children, siblings ) {
142  if ( count++ == index )
143  ui->row.settings = settings;
144  }
145 
146  /* Include any applicable settings */
148 
149  /* Skip inapplicable settings */
150  if ( ! setting_applies ( ui->settings, setting ) )
151  continue;
152 
153  /* Skip duplicate settings */
154  if ( previous && ( setting_cmp ( setting, previous ) == 0 ) )
155  continue;
156  previous = setting;
157 
158  /* Read current setting value and origin */
159  if ( count++ == index ) {
161  &ui->row.origin,
162  &ui->row.setting, &ui->row.buf );
163  }
164  }
165 
166  /* Initialise edit box */
167  init_editbox ( &ui->row.editbox, &ui->row.buf, NULL, ui->row.row,
169  offsetof ( typeof ( *text ), u.setting.value ) ),
170  sizeof ( text->u.setting.value ), 0 );
171 
172  return count;
173 }
174 
175 /**
176  * Copy string without NUL termination
177  *
178  * @v dest Destination
179  * @v src Source
180  * @v len Maximum length of destination
181  * @ret len Length of (unterminated) string
182  */
183 static size_t string_copy ( char *dest, const char *src, size_t len ) {
184  size_t src_len;
185 
186  src_len = strlen ( src );
187  if ( len > src_len )
188  len = src_len;
189  memcpy ( dest, src, len );
190  return len;
191 }
192 
193 /**
194  * Draw setting row
195  *
196  * @v ui Settings UI
197  */
198 static void draw_setting_row ( struct settings_ui *ui ) {
199  SETTING_ROW_TEXT ( COLS ) text;
200  unsigned int curs_offset;
201  const char *value;
202 
203  /* Fill row with spaces */
204  memset ( &text, ' ', sizeof ( text ) );
205  text.nul = '\0';
206 
207  /* Construct row content */
208  if ( ui->row.settings ) {
209 
210  /* Construct space-padded name */
211  value = ( ( ui->row.settings == ui->settings->parent ) ?
212  ".." : ui->row.settings->name );
213  curs_offset = string_copy ( text.u.settings.name, value,
214  sizeof ( text.u.settings.name ) );
215  text.u.settings.name[curs_offset] = '/';
216  curs_offset += offsetof ( typeof ( text ), u.settings );
217 
218  } else {
219 
220  /* Construct dot-padded name */
221  memset ( text.u.setting.name, '.',
222  sizeof ( text.u.setting.name ) );
223  string_copy ( text.u.setting.name, ui->row.setting.name,
224  sizeof ( text.u.setting.name ) );
225 
226  /* Construct space-padded value */
227  value = ui->row.buf;
228  if ( ! ( value && value[0] ) )
229  value = "<not specified>";
230  curs_offset = string_copy ( text.u.setting.value, value,
231  sizeof ( text.u.setting.value ) );
232  curs_offset += offsetof ( typeof ( text ), u.setting.value );
233  }
234 
235  /* Print row */
236  if ( ( ui->row.origin == ui->settings ) || ( ui->row.settings != NULL ))
237  attron ( A_BOLD );
238  mvprintw ( ui->row.row, SETTINGS_LIST_COL, "%s", text.start );
239  attroff ( A_BOLD );
240  move ( ui->row.row, ( SETTINGS_LIST_COL + curs_offset ) );
241 }
242 
243 /**
244  * Edit setting ui
245  *
246  * @v ui Settings UI
247  * @v key Key pressed by user
248  * @ret key Key returned to application, or zero
249  */
250 static int edit_setting ( struct settings_ui *ui, int key ) {
251  assert ( ui->row.setting.name != NULL );
252  ui->row.editing = 1;
253  return edit_editbox ( &ui->row.editbox, key );
254 }
255 
256 /**
257  * Save setting ui value back to configuration settings
258  *
259  * @v ui Settings UI
260  */
261 static int save_setting ( struct settings_ui *ui ) {
262  assert ( ui->row.setting.name != NULL );
263  return storef_setting ( ui->settings, &ui->row.setting, ui->row.buf );
264 }
265 
266 /**
267  * Print message centred on specified row
268  *
269  * @v row Row
270  * @v fmt printf() format string
271  * @v args printf() argument list
272  */
273 static void vmsg ( unsigned int row, const char *fmt, va_list args ) {
274  char buf[COLS];
275  size_t len;
276 
277  len = vsnprintf ( buf, sizeof ( buf ), fmt, args );
278  mvprintw ( row, ( ( COLS - len ) / 2 ), "%s", buf );
279 }
280 
281 /**
282  * Print message centred on specified row
283  *
284  * @v row Row
285  * @v fmt printf() format string
286  * @v .. printf() arguments
287  */
288 static void msg ( unsigned int row, const char *fmt, ... ) {
289  va_list args;
290 
291  va_start ( args, fmt );
292  vmsg ( row, fmt, args );
293  va_end ( args );
294 }
295 
296 /**
297  * Clear message on specified row
298  *
299  * @v row Row
300  */
301 static void clearmsg ( unsigned int row ) {
302  move ( row, 0 );
303  clrtoeol();
304 }
305 
306 /**
307  * Print alert message
308  *
309  * @v fmt printf() format string
310  * @v args printf() argument list
311  */
312 static void valert ( const char *fmt, va_list args ) {
313  clearmsg ( ALERT_ROW );
315  vmsg ( ALERT_ROW, fmt, args );
316  sleep ( 2 );
318  clearmsg ( ALERT_ROW );
319 }
320 
321 /**
322  * Print alert message
323  *
324  * @v fmt printf() format string
325  * @v ... printf() arguments
326  */
327 static void alert ( const char *fmt, ... ) {
328  va_list args;
329 
330  va_start ( args, fmt );
331  valert ( fmt, args );
332  va_end ( args );
333 }
334 
335 /**
336  * Draw title row
337  *
338  * @v ui Settings UI
339  */
340 static void draw_title_row ( struct settings_ui *ui ) {
341  const char *name;
342 
343  clearmsg ( TITLE_ROW );
344  name = settings_name ( ui->settings );
345  attron ( A_BOLD );
346  msg ( TITLE_ROW, PRODUCT_SHORT_NAME " configuration settings%s%s",
347  ( name[0] ? " - " : "" ), name );
348  attroff ( A_BOLD );
349 }
350 
351 /**
352  * Draw information row
353  *
354  * @v ui Settings UI
355  */
356 static void draw_info_row ( struct settings_ui *ui ) {
357  char buf[32];
358 
359  /* Draw nothing unless this row represents a setting */
360  clearmsg ( INFO_ROW );
361  clearmsg ( INFO_ROW + 1 );
362  if ( ! ui->row.setting.name )
363  return;
364 
365  /* Determine a suitable setting name */
366  setting_name ( ( ui->row.origin ?
367  ui->row.origin : ui->settings ),
368  &ui->row.setting, buf, sizeof ( buf ) );
369 
370  /* Draw row */
371  attron ( A_BOLD );
372  msg ( INFO_ROW, "%s - %s", buf, ui->row.setting.description );
373  attroff ( A_BOLD );
374  color_set ( CPAIR_URL, NULL );
375  msg ( ( INFO_ROW + 1 ), PRODUCT_SETTING_URI, ui->row.setting.name );
377 }
378 
379 /**
380  * Draw instruction row
381  *
382  * @v ui Settings UI
383  */
384 static void draw_instruction_row ( struct settings_ui *ui ) {
385 
387  if ( ui->row.editing ) {
389  "Enter - accept changes" INSTRUCTION_PAD
390  "Ctrl-C - discard changes" );
391  } else {
393  "%sCtrl-X - exit configuration utility",
394  ( ( ui->row.origin == ui->settings ) ?
395  "Ctrl-D - delete setting" INSTRUCTION_PAD : "" ) );
396  }
397 }
398 
399 /**
400  * Draw the current block of setting rows
401  *
402  * @v ui Settings UI
403  */
404 static void draw_setting_rows ( struct settings_ui *ui ) {
405  unsigned int i;
406 
407  /* Draw ellipses before and/or after the list as necessary */
409  mvaddstr ( ( SETTINGS_LIST_ROW - 1 ), ( SETTINGS_LIST_COL + 1 ),
410  jump_scroll_is_first ( &ui->scroll ) ? " " : "..." );
412  ( SETTINGS_LIST_COL + 1 ),
413  jump_scroll_is_last ( &ui->scroll ) ? " " : "..." );
415 
416  /* Draw visible settings. */
417  for ( i = 0 ; i < SETTINGS_LIST_ROWS ; i++ ) {
418  if ( ( ui->scroll.first + i ) < ui->scroll.count ) {
419  select_setting_row ( ui, ( ui->scroll.first + i ) );
420  draw_setting_row ( ui );
421  } else {
422  clearmsg ( SETTINGS_LIST_ROW + i );
423  }
424  }
425 }
426 
427 /**
428  * Select settings block
429  *
430  * @v ui Settings UI
431  * @v settings Settings block
432  */
433 static void select_settings ( struct settings_ui *ui,
434  struct settings *settings ) {
435 
437  ui->scroll.count = select_setting_row ( ui, 0 );
439  ui->scroll.current = 0;
440  ui->scroll.first = 0;
441  draw_title_row ( ui );
442  draw_setting_rows ( ui );
443  select_setting_row ( ui, 0 );
444 }
445 
446 static int main_loop ( struct settings *settings ) {
447  struct settings_ui ui;
448  unsigned int previous;
449  int redraw = 1;
450  int move;
451  int key;
452  int rc;
453 
454  /* Print initial screen content */
456  memset ( &ui, 0, sizeof ( ui ) );
457  select_settings ( &ui, settings );
458 
459  while ( 1 ) {
460 
461  /* Redraw rows if necessary */
462  if ( redraw ) {
463  draw_info_row ( &ui );
464  draw_instruction_row ( &ui );
465  color_set ( ( ui.row.editing ?
467  draw_setting_row ( &ui );
469  curs_set ( ui.row.editing );
470  redraw = 0;
471  }
472 
473  /* Edit setting, if we are currently editing */
474  if ( ui.row.editing ) {
475 
476  /* Sanity check */
477  assert ( ui.row.setting.name != NULL );
478 
479  /* Redraw edit box */
481  draw_editbox ( &ui.row.editbox );
483 
484  /* Process keypress */
485  key = edit_setting ( &ui, getkey ( 0 ) );
486  switch ( key ) {
487  case CR:
488  case LF:
489  if ( ( rc = save_setting ( &ui ) ) != 0 )
490  alert ( " %s ", strerror ( rc ) );
491  /* Fall through */
492  case CTRL_C:
493  select_setting_row ( &ui, ui.scroll.current );
494  redraw = 1;
495  break;
496  default:
497  /* Do nothing */
498  break;
499  }
500 
501  continue;
502  }
503 
504  /* Otherwise, navigate through settings */
505  key = getkey ( 0 );
506  move = jump_scroll_key ( &ui.scroll, key );
507  if ( move ) {
508  previous = ui.scroll.current;
509  jump_scroll_move ( &ui.scroll, move );
510  if ( ui.scroll.current != previous ) {
511  draw_setting_row ( &ui );
512  redraw = 1;
513  if ( jump_scroll ( &ui.scroll ) )
514  draw_setting_rows ( &ui );
515  select_setting_row ( &ui, ui.scroll.current );
516  }
517  continue;
518  }
519 
520  /* Handle non-navigation keys */
521  switch ( key ) {
522  case CTRL_D:
523  if ( ! ui.row.setting.name )
524  break;
525  if ( ( rc = delete_setting ( ui.settings,
526  &ui.row.setting ) ) != 0 ){
527  alert ( " %s ", strerror ( rc ) );
528  }
529  select_setting_row ( &ui, ui.scroll.current );
530  redraw = 1;
531  break;
532  case CTRL_X:
533  select_setting_row ( &ui, -1U );
534  return 0;
535  case CR:
536  case LF:
537  if ( ui.row.settings ) {
538  select_settings ( &ui, ui.row.settings );
539  redraw = 1;
540  }
541  /* Fall through */
542  default:
543  if ( ui.row.setting.name ) {
544  edit_setting ( &ui, key );
545  redraw = 1;
546  }
547  break;
548  }
549  }
550 }
551 
552 int settings_ui ( struct settings *settings ) {
553  int rc;
554 
555  initscr();
556  start_color();
558  curs_set ( 0 );
559  erase();
560 
561  rc = main_loop ( settings );
562 
563  endwin();
564 
565  return rc;
566 }
int getkey(unsigned long timeout)
Get single keypress.
Definition: getkey.c:71
MuCurses header file.
int editing
Editing in progress flag.
Definition: settings_ui.c:98
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
const char * name
Definition: ath9k_hw.c:1984
#define va_end(ap)
Definition: stdarg.h:9
Editable text box widget.
#define PRODUCT_SHORT_NAME
Definition: branding.h:28
int erase(void)
Completely clear the screen.
Definition: clear.c:97
int settings_ui(struct settings *settings)
Definition: settings_ui.c:552
static void draw_setting_row(struct settings_ui *ui)
Draw setting row.
Definition: settings_ui.c:198
int fetchf_setting_copy(struct settings *settings, const struct setting *setting, struct settings **origin, struct setting *fetched, char **value)
Fetch copy of formatted value of setting.
Definition: settings.c:1276
struct settings * parent
Parent settings block.
Definition: settings.h:138
static int attroff(int attrs)
Definition: curses.h:508
#define CPAIR_EDIT
Editable text.
Definition: ansicol.h:49
A settings user interface.
Definition: settings_ui.c:104
static int main_loop(struct settings *settings)
Definition: settings_ui.c:446
struct settings_ui_row row
Current row.
Definition: settings_ui.c:110
static void clearmsg(unsigned int row)
Clear message on specified row.
Definition: settings_ui.c:301
static void const void * src
Definition: crypto.h:244
static int delete_setting(struct settings *settings, const struct setting *setting)
Delete setting.
Definition: settings.h:531
#define start_color()
Definition: curses.h:396
int endwin(void)
Finalise console environment.
Definition: wininit.c:31
A settings user interface row.
Definition: settings_ui.c:77
#define mvprintw(y, x, fmt,...)
Definition: curses.h:648
const char * settings_name(struct settings *settings)
Return settings block name.
Definition: settings.c:345
#define SETTINGS_LIST_ROW
Definition: settings_ui.c:49
static void draw_instruction_row(struct settings_ui *ui)
Draw instruction row.
Definition: settings_ui.c:384
Branding configuration.
#define offsetof(type, field)
Get offset of a field within a structure.
Definition: stddef.h:24
const char * description
Description.
Definition: settings.h:30
static unsigned int select_setting_row(struct settings_ui *ui, unsigned int index)
Select a setting.
Definition: settings_ui.c:120
A jump scroller.
Definition: jumpscroll.h:13
#define CPAIR_NORMAL
Normal text.
Definition: ansicol.h:40
struct settings * origin
Configuration setting origin.
Definition: settings_ui.c:87
const char * name
Name.
Definition: settings.h:28
#define SETTINGS
Configuration setting table.
Definition: settings.h:53
#define CTRL_X
Definition: keys.h:41
static void valert(const char *fmt, va_list args)
Print alert message.
Definition: settings_ui.c:312
static int save_setting(struct settings_ui *ui)
Save setting ui value back to configuration settings.
Definition: settings_ui.c:261
void * memcpy(void *dest, const void *src, size_t len) __nonnull
struct settings * settings_target(struct settings *settings)
Redirect to target settings block.
Definition: settings.c:549
static void draw_setting_rows(struct settings_ui *ui)
Draw the current block of setting rows.
Definition: settings_ui.c:404
void init_editbox(struct edit_box *box, char **buf, WINDOW *win, unsigned int row, unsigned int col, unsigned int width, unsigned int flags)
Initialise text box widget.
Definition: editbox.c:49
WINDOW * initscr(void)
Initialise console environment.
Definition: wininit.c:17
static void draw_info_row(struct settings_ui *ui)
Draw information row.
Definition: settings_ui.c:356
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
#define PRODUCT_SETTING_URI
Definition: branding.h:170
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition: list.h:431
unsigned int first
First visible item.
Definition: jumpscroll.h:21
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
unsigned int count
Total number of items.
Definition: jumpscroll.h:17
int jump_scroll(struct jump_scroller *scroll)
Jump scroll to new page (if applicable)
Definition: jumpscroll.c:119
#define CPAIR_ALERT
Error text.
Definition: ansicol.h:52
#define CTRL_C
Definition: keys.h:20
static int edit_editbox(struct edit_box *box, int key) __nonnull
Edit text box widget.
Definition: editbox.h:57
#define CPAIR_URL
URL text.
Definition: ansicol.h:55
struct settings * settings
Target configuration settings block.
Definition: settings_ui.c:82
An editable text box widget.
Definition: editbox.h:16
User interaction.
static void * dest
Definition: strings.h:176
#define ALERT_ROW
Definition: settings_ui.c:53
#define TITLE_ROW
Definition: settings_ui.c:48
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
Configuration settings.
int storef_setting(struct settings *settings, const struct setting *setting, const char *value)
Store formatted value of setting.
Definition: settings.c:1319
static void vmsg(unsigned int row, const char *fmt, va_list args)
Print message centred on specified row.
Definition: settings_ui.c:273
struct settings * settings
Settings block.
Definition: settings_ui.c:106
Option configuration console.
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
static void select_settings(struct settings_ui *ui, struct settings *settings)
Select settings block.
Definition: settings_ui.c:433
int setting_applies(struct settings *settings, const struct setting *setting)
Check applicability of setting.
Definition: settings.c:570
static int clrtoeol(void)
Definition: curses.h:553
#define for_each_table_entry(pointer, table)
Iterate through all entries within a linker table.
Definition: tables.h:385
size_t strlen(const char *src)
Get length of string.
Definition: string.c:243
A settings block.
Definition: settings.h:132
#define INSTRUCTION_ROW
Definition: settings_ui.c:54
#define CPAIR_SEPARATOR
Unselectable text (e.g.
Definition: ansicol.h:46
const char * name
Name.
Definition: settings.h:136
#define INFO_ROW
Definition: settings_ui.c:52
#define COLS
Definition: curses.h:111
#define INSTRUCTION_PAD
Definition: settings_ui.c:55
#define LF
Definition: keys.h:47
A setting.
Definition: settings.h:23
void draw_editbox(struct edit_box *box)
Draw text box widget.
Definition: editbox.c:68
char * buf
Dynamically allocated buffer for setting's value.
Definition: settings_ui.c:100
static int jump_scroll_is_last(struct jump_scroller *scroll)
Check if jump scroller is currently on last page.
Definition: jumpscroll.h:41
int curs_set(int visibility)
Set cursor visibility.
Definition: mucurses.c:153
uint32_t len
Length.
Definition: ena.h:14
__builtin_va_list va_list
Definition: stdarg.h:6
Key definitions.
unsigned int row
Screen row.
Definition: settings_ui.c:94
struct setting setting
Configuration setting.
Definition: settings_ui.c:92
static void alert(const char *fmt,...)
Print alert message.
Definition: settings_ui.c:327
uint16_t count
Number of entries.
Definition: ena.h:22
struct jump_scroller scroll
Jump scroller.
Definition: settings_ui.c:108
static int jump_scroll_is_first(struct jump_scroller *scroll)
Check if jump scroller is currently on first page.
Definition: jumpscroll.h:30
struct edit_box editbox
Edit box widget used for editing setting.
Definition: settings_ui.c:96
static int move(int y, int x)
Definition: curses.h:593
#define CPAIR_SELECT
Highlighted text.
Definition: ansicol.h:43
#define SETTINGS_LIST_COL
Definition: settings_ui.c:50
int jump_scroll_key(struct jump_scroller *scroll, int key)
Jump scrolling.
Definition: jumpscroll.c:42
Jump scrolling.
#define CR
Definition: keys.h:48
union @17 u
int ssize_t const char * fmt
Definition: vsprintf.h:72
unsigned int rows
Maximum number of visible rows.
Definition: jumpscroll.h:15
struct list_head children
Child settings blocks.
Definition: settings.h:142
#define color_set(cpno, opts)
Definition: curses.h:240
static void draw_title_row(struct settings_ui *ui)
Draw title row.
Definition: settings_ui.c:340
typeof(acpi_finder=acpi_find)
ACPI table finder.
Definition: acpi.c:45
#define CTRL_D
Definition: keys.h:21
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21
#define va_start(ap, last)
Definition: stdarg.h:7
#define A_BOLD
Definition: curses.h:138
static size_t string_copy(char *dest, const char *src, size_t len)
Copy string without NUL termination.
Definition: settings_ui.c:183
static int edit_setting(struct settings_ui *ui, int key)
Edit setting ui.
Definition: settings_ui.c:250
unsigned int current
Currently selected item.
Definition: jumpscroll.h:19
#define SETTINGS_LIST_ROWS
Definition: settings_ui.c:51
int setting_name(struct settings *settings, const struct setting *setting, char *buf, size_t len)
Return full setting name.
Definition: settings.c:1606
int setting_cmp(const struct setting *a, const struct setting *b)
Compare two settings.
Definition: settings.c:1120
unsigned int sleep(unsigned int secs)
Sleep (interruptibly) for a fixed number of seconds.
Definition: timer.c:133
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
String functions.
static int mvaddstr(int y, int x, const char *str)
Definition: curses.h:617
#define SETTING_ROW_TEXT(cols)
Layout of text within a setting row.
Definition: settings_ui.c:58
union @382 key
Sense key.
Definition: crypto.h:284
ANSI colours.
int jump_scroll_move(struct jump_scroller *scroll, int move)
Move scroller.
Definition: jumpscroll.c:78
static int attron(int attrs)
Definition: curses.h:512
int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
Write a formatted string to a buffer.
Definition: vsprintf.c:351
void * memset(void *dest, int character, size_t len) __nonnull
static void msg(unsigned int row, const char *fmt,...)
Print message centred on specified row.
Definition: settings_ui.c:288