tools/perf/ui/tui/util.c
Source file repositories/reference/linux-study-clean/tools/perf/ui/tui/util.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/ui/tui/util.c- Extension
.c- Size
- 5611 bytes
- Lines
- 275
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
signal.hstdbool.hstring.hstdlib.hsys/ttydefaults.h../browser.h../keysyms.h../helpline.h../ui.h../util.h../libslang.h
Detected Declarations
function ui_browser__argv_writefunction popup_menu__runfunction ui__popup_menufunction ui_browser__input_windowfunction __ui__info_windowfunction ui__info_windowfunction ui__question_windowfunction ui__help_windowfunction ui__dialog_yesnofunction __ui__warningfunction perf_tui__errorfunction perf_tui__warning
Annotated Snippet
switch (key) {
case K_RIGHT:
case K_ENTER:
key = menu->index;
break;
case K_LEFT:
case K_ESC:
case 'q':
case CTRL('c'):
key = -1;
break;
default:
if (keyp) {
*keyp = key;
key = menu->nr_entries;
break;
}
continue;
}
break;
}
ui_browser__hide(menu);
return key;
}
int ui__popup_menu(int argc, char * const argv[], int *keyp)
{
struct ui_browser menu = {
.entries = (void *)argv,
.refresh = ui_browser__argv_refresh,
.seek = ui_browser__argv_seek,
.write = ui_browser__argv_write,
.nr_entries = argc,
};
return popup_menu__run(&menu, keyp);
}
int ui_browser__input_window(const char *title, const char *text, char *input,
const char *exit_msg, int delay_secs)
{
int x, y, len, key;
int max_len = 60, nr_lines = 0;
static char buf[50];
const char *t;
t = text;
while (1) {
const char *sep = strchr(t, '\n');
if (sep == NULL)
sep = strchr(t, '\0');
len = sep - t;
if (max_len < len)
max_len = len;
++nr_lines;
if (*sep == '\0')
break;
t = sep + 1;
}
mutex_lock(&ui__lock);
max_len += 2;
nr_lines += 8;
y = SLtt_Screen_Rows / 2 - nr_lines / 2;
x = SLtt_Screen_Cols / 2 - max_len / 2;
SLsmg_set_color(0);
SLsmg_draw_box(y, x++, nr_lines, max_len);
if (title) {
SLsmg_gotorc(y, x + 1);
SLsmg_write_string(title);
}
SLsmg_gotorc(++y, x);
nr_lines -= 7;
max_len -= 2;
SLsmg_write_wrapped_string((unsigned char *)text, y, x,
nr_lines, max_len, 1);
y += nr_lines;
len = 5;
while (len--) {
SLsmg_gotorc(y + len - 1, x);
SLsmg_write_nstring(" ", max_len);
}
SLsmg_draw_box(y++, x + 1, 3, max_len - 2);
SLsmg_gotorc(y + 3, x);
SLsmg_write_nstring(exit_msg, max_len);
Annotation
- Immediate include surface: `signal.h`, `stdbool.h`, `string.h`, `stdlib.h`, `sys/ttydefaults.h`, `../browser.h`, `../keysyms.h`, `../helpline.h`.
- Detected declarations: `function ui_browser__argv_write`, `function popup_menu__run`, `function ui__popup_menu`, `function ui_browser__input_window`, `function __ui__info_window`, `function ui__info_window`, `function ui__question_window`, `function ui__help_window`, `function ui__dialog_yesno`, `function __ui__warning`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.