2
3
4
5
6
7
8
9
12
13
14
23#include <sys/sysmacros.h>
35
36
37
38
39
40
41
42
43
44
45
46
47
86
87
88
89
90
91
92
96 ui_log(INFO,
_(
"view_full_screen_resize: lines=%d, cols=%d, ln_win_lines=%d, ln_win_cols=%d, scroll_lines=%d"), init
->view->lines, init
->view->cols, init
->view->ln_win_lines, init
->view->ln_win_cols, init
->view->scroll_lines);
103
104
105
106
107
108
109
121 _(
"%s:%d view->lines=%d, view->cols=%d, view->maxrows=%d, view->maxcols=%d"),
123 view->lines, view->cols, view->smaxrow, view->smaxcol);
124 write_cmenu_log(em0);
138
139
140
141
142
143
144
152 ui_bkgd(view->sfc, BOX, &cell_magenta_bg);
153 ui_bkgdset(view->sfc, BOX, &cell_magenta_bg);
154 ui_mvwaddstr(view->sfc, BOX, 1, 1,
"-- BOX --");
164 ui_bkgd(view->sfc, WIN, &cell_cyan_bg);
165 ui_mvwaddstr(view->sfc, WIN, 1, 1,
"-- WIN --");
178 ui_bkgd(view->sfc, LNNO, &cell_blue_bg);
179 ui_bkgdset(view->sfc, LNNO, &cell_blue_bg);
180 ui_mvwaddstr(view->sfc, LNNO, 1, 1,
"-- LNNO --");
194 ui_bkgd(view->sfc, CMDLN, &cell_red_bg);
195 ui_bkgdset(view->sfc, CMDLN, &cell_red_bg);
196 ui_mvwaddstr(view->sfc, CMDLN, 1, 1,
"-- CMDLN --");
215 ui_bkgd(view->sfc, PAD, &cell_yellow_bg);
216 ui_bkgdset(view->sfc, PAD, &cell_yellow_bg);
217 ui_mvwaddstr(view->sfc, PAD, 1, 1,
"-- PAD --");
224
225
226
227
237
238
239
240
241
242
243
244
249
250
251 uint scr_lines, scr_cols;
254 ssnprintf(em0, MAXLEN - 1,
255 _(
"%s:%d=%d calc lines=%d, cols=%d, begy=%d, begx=%d"),
256 __FILE__, __LINE__, 526, view->lines, view->cols, view->begy, view->begx);
257 write_cmenu_log(em0);
261 view
->cols = scr_cols - 2;
265 uint lines =
max(scr_lines / 10, 8);
267 if (view
->lines > scr_lines - 3)
272 uint cols =
max(scr_cols / 3, 40);
274 if (view
->cols > scr_cols - 2)
275 view
->cols = scr_cols - 2;
298 ssnprintf(em0, MAXLEN - 1,
299 _(
"%s:%d calc BOX lines=%d, cols=%d, begy=%d, begx=%d"),
300 __FILE__, __LINE__, view->lines + 2, view->cols + 2, view->begy, view->begx);
301 write_cmenu_log(em0);
302 ssnprintf(em0, MAXLEN - 1,
303 _(
"%s:%d calc WIN lines=%d, cols=%d, begy=%d, begx=%d"),
304 __FILE__, __LINE__, view->lines, view->cols, 1, 1);
305 write_cmenu_log(em0);
306 ssnprintf(em0, MAXLEN - 1,
307 _(
"%s:%d calc CMDLN lines=%d, cols=%d, begy=%d, begx=%d"),
308 __FILE__, __LINE__, 1, view->cols, view->lines - 1, 1);
309 write_cmenu_log(em0);
310 ssnprintf(em0, MAXLEN - 1,
311 _(
"%s:%d calc LNNO lines=%d, cols=%d, begy=%d, begx=%d"),
312 __FILE__, __LINE__, view->lines - 1, view->ln_win_cols, 0, 0);
313 write_cmenu_log(em0);
314 ssnprintf(em0, MAXLEN - 1,
315 _(
"%s:%d calc PAD lines=%d, cols=%d, begy=%d, begx=%d"),
316 __FILE__, __LINE__, view->lines - 1, view->cols - view->ln_win_cols, 0, view->ln_win_cols);
317 write_cmenu_log(em0);
322
323
324
325
326
327
328
329
330
341 if (strcmp(file_name,
"-") == 0) {
342 file_name =
_(
"/dev/stdin");
347 if (pipe(pipe_fd) == -1) {
352 if ((pid = fork()) == -1) {
358 int dev_null = open(
_(
"/dev/null"), O_WRONLY);
359 if (dev_null == -1) {
360 ui_perror(_(
"open(/dev/null) failed in init_pick child process"));
363 dup2(dev_null, STDERR_FILENO);
366 dup2(pipe_fd[
P_WRITE], STDOUT_FILENO);
368 execvp(s_argv[0], s_argv);
383 view
->in_fd = dup(STDIN_FILENO);
388 view
->in_fd = open(file_name, O_RDONLY);
398 if (fstat(view
->in_fd, &sb) == -1) {
417 if (!S_ISREG(sb.st_mode))
424 view
->tmp_fd = memfd_create(
_(
"view_input"), MFD_CLOEXEC);
425 if (view
->in_fd < 0 || errno != 0) {
429 __LINE__ - 4
, errno
);
437 ssize_t bytes_read = 0;
459 bytes_read = read(view
->in_fd, buf,
sizeof(buf));
460 if (bytes_read > 0) {
461 if (write(view
->tmp_fd, buf, bytes_read) != bytes_read)
463 }
else if (bytes_read == 0)
468 if (fstat(view
->tmp_fd, &sb) == -1) {
472 __LINE__ - 4
, errno
);
483 waitpid(-1,
nullptr, 0);
488 if (view
->buf == MAP_FAILED) {
503 for (idx = 0; idx <
NMARKS; idx++)
char stdio_names_str[4096]
char * stdio_fdnames(char *, char *)
UiSurface * ui_surface_box(UiSurface *parent, ss_t p, uint lines, uint cols, uint y, uint x, const char *title)
Create a new UI surface with a border box and optional title.
void ui_render()
Render the UI by updating panels and refreshing the display.
UiSurface * ui_surface_new(ss_t w, UiSurface *parent, ss_t p, uint lines, uint cols, uint y, uint x)
Create a new UI surface with the specified parameters.
int ui_setscrreg(UiSurface *s, ss_t w, uint top, uint bottom)
Set the scrolling region for a UiSurface.
int ui_idcok(UiSurface *s, ss_t w, bool enable)
Enable or disable the use of the insert/delete character capabilities for a UiSurface.
int ui_surface_addwin(UiSurface *s, ss_t w, ss_t p, uint lines, uint cols, uint y, uint x)
Add a new window to the specified UiSurface.
void ui_surface_destroy(UiSurface *s)
Destroy a UiSurface, cleaning up its windows and panels.
int ui_surface_addpad(UiSurface *s, ss_t w, ss_t view_win, uint lines, uint cols, uint y, uint x, bool hidden)
Add a new pad to the specified UiSurface.
int ui_bkgd(UiSurface *s, ss_t w, const UiCell *cell)
Set the background of a specific window within a UiSurface.
void ui_restore_wins()
Restore the state of all windows in the UI. This function refreshes the standard screen and all surfa...
int ui_idlok(UiSurface *s, ss_t w, bool enable)
Enable or disable the use of the insert/delete line capabilities for a UiSurface.
void ui_get_screen_size(uint *lines, uint *cols)
Get the current screen size (number of lines and columns).
int ui_erase()
Erase the entire screen.
int ui_scrollok(UiSurface *s, ss_t w, bool enable)
Enable or disable scrolling for a UiSurface.
void ui_get_caps(UiCaps *caps)
Get the UI backend capabilities.
int ui_bkgdset(UiSurface *s, ss_t w, const UiCell *cell)
Set the background for new content to be written to a specific window within a UiSurface.
int ui_werase(UiSurface *s, ss_t w)
Erase the contents of a UiSurface or all surfaces.
int ui_keypad(UiSurface *s, ss_t w, bool enable)
Enable or disable the keypad for a UiSurface.
#define UIKEY_STREAM_DATA
void ui_flush_input()
Flush any pending input events from the NotCurses context. This function discards any input events th...
void ui_abend(int ec, char *s)
Convert multibyte string to complex character array.
int ui_border_title(UiSurface *sfc, ss_t w, const char *title)
Draw a box with a title around the specified window.
void ui_log_write(const UiLogLevel level, const char *file, const char *func, const int line, const char *fmt,...)
void view_full_screen_resize(Init *)
Resize the full screen view and its components.
void view_boxwin_resize(Init *)
Resize the current window and its box.
void cmenu_abend(Init *init, int ec, char *s)
size_t strnz__cpy(char *, const char *, size_t)
safer alternative to strncpy
size_t ssnprintf(char *, size_t, const char *,...)
Custom safe string formatting utility (Variadic version).
int str_to_args(char **, char *, uint)
Converts a string into an array of argument strings.
bool expand_tilde(char *, uint)
Expand a tilde (~) in a file path to the user's home directory.
size_t strnz__cat(char *, const char *, size_t)
safer alternative to strncat
char * strerror__r(int errnum, char *buf, size_t buflen)
A thread-safe alternative to strerror() that writes the error message corresponding to errnum into th...
int destroy_argv(uint argc, char **argv)
Deallocates memory allocated for argument strings in argv.
bool base_name(char *, char *)
Returns the base name of a file specification.
void view_calc_boxwin_dimensions(Init *)
Calculate the dimensions and position of the box window for C-Menu View.
int init_view_full_screen(Init *init)
Initialize C-Menu View in full screen mode.
int init_view_boxwin(Init *init)
Initialize the C-Menu View in box window mode.
void view_calc_full_screen_dimensions(Init *)
Calculate the dimensions for full screen mode.
int view_init_input(Init *init, char *file_name)
Initialize the input for the C-Menu View.
void sig_prog_mode()
Set up signal handlers for interrupt signals.
int ui_perror(char *emsg_str)
Display a simple error message window or print to stderr.
void ui_unregister_read_fd(int fd)
Unregister an external file descriptor from polling.
void ui_register_read_fd(int fd, int token_id)
Register an external file descriptor for polling.
int ui_timeout_prompt(char *msg0, char *msg1, uint timeout_ms, uint timeout_secs)
Display a timeout prompt window or print to stderr.
int ui_poll_reg_read_fd(int timeout_ms)
Poll for input on registered external files.
int ui_display_error(char *msg0, char *msg1, char *msg2, char *msg3)
Display an error message window or print to stderr.
char provider_cmd[MAXLEN]
char cur_file_str[MAXLEN]