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
56 ui_log(INFO,
"%s",
em0);
60 ui_log(INFO,
_(
"created view->sfc"));
65 if (view
->sfc->lnno ==
nullptr) {
67 ui_log(INFO,
"%s",
em0);
70 ui_log(INFO,
_(
"created view->sfc->lnno"));
78 if (view
->sfc->cmdln ==
nullptr) {
80 ui_log(INFO,
"%s",
em0);
83 ui_log(INFO,
_(
"created view->sfc->cmdln"));
92 ui_log(INFO,
_(
"created view->sfc->mplane[PAD]"));
93 if (view
->sfc->pad ==
nullptr) {
95 ui_log(INFO,
"%s",
em0);
104
105
106
107
108
109
110
114 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);
121
122
123
124
125
126
127
139 _(
"%s:%d view->lines=%d, view->cols=%d, view->maxrows=%d, view->maxcols=%d"),
141 view->lines, view->cols, view->smaxrow, view->smaxcol);
142 write_cmenu_log(em0);
155
156
157
158
159
160
161
194
195
196
197
207
208
209
210
211
212
213
214
219
220
221 uint scr_lines, scr_cols;
224 ssnprintf(em0, MAXLEN - 1,
225 _(
"%s:%d=%d calc lines=%d, cols=%d, begy=%d, begx=%d"),
226 __FILE__, __LINE__, 526, view->lines, view->cols, view->begy, view->begx);
227 write_cmenu_log(em0);
231 view
->cols = scr_cols - 2;
235 uint lines =
max(scr_lines / 10, 8);
237 if (view
->lines > scr_lines - 3)
242 uint cols =
max(scr_cols / 3, 40);
244 if (view
->cols > scr_cols - 2)
245 view
->cols = scr_cols - 2;
266 ssnprintf(em0, MAXLEN - 1,
267 _(
"%s:%d calc BOX lines=%d, cols=%d, begy=%d, begx=%d"),
268 __FILE__, __LINE__, view->lines + 2, view->cols + 2, view->begy, view->begx);
269 write_cmenu_log(em0);
270 ssnprintf(em0, MAXLEN - 1,
271 _(
"%s:%d calc WIN lines=%d, cols=%d, begy=%d, begx=%d"),
272 __FILE__, __LINE__, view->lines, view->cols, 1, 1);
273 write_cmenu_log(em0);
274 ssnprintf(em0, MAXLEN - 1,
275 _(
"%s:%d calc CMDLN lines=%d, cols=%d, begy=%d, begx=%d"),
276 __FILE__, __LINE__, 1, view->cols, view->lines - 1, 1);
277 write_cmenu_log(em0);
278 ssnprintf(em0, MAXLEN - 1,
279 _(
"%s:%d calc LNNO lines=%d, cols=%d, begy=%d, begx=%d"),
280 __FILE__, __LINE__, view->lines - 1, view->ln_win_cols, 0, 0);
281 write_cmenu_log(em0);
282 ssnprintf(em0, MAXLEN - 1,
283 _(
"%s:%d calc PAD lines=%d, cols=%d, begy=%d, begx=%d"),
284 __FILE__, __LINE__, view->lines - 1, view->cols - view->ln_win_cols, 0, view->ln_win_cols);
285 write_cmenu_log(em0);
290
291
292
293
294
295
296
297
298
309 if (strcmp(file_name,
"-") == 0) {
310 file_name =
_(
"/dev/stdin");
315 if (pipe(pipe_fd) == -1) {
320 if ((pid = fork()) == -1) {
326 int dev_null = open(
_(
"/dev/null"), O_WRONLY);
327 if (dev_null == -1) {
328 ui_perror(_(
"open(/dev/null) failed in init_pick child process"));
331 dup2(dev_null, STDERR_FILENO);
334 dup2(pipe_fd[
P_WRITE], STDOUT_FILENO);
336 execvp(s_argv[0], s_argv);
351 view
->in_fd = dup(STDIN_FILENO);
356 view
->in_fd = open(file_name, O_RDONLY);
366 if (fstat(view
->in_fd, &sb) == -1) {
385 if (!S_ISREG(sb.st_mode))
392 view
->tmp_fd = memfd_create(
_(
"view_input"), MFD_CLOEXEC);
393 if (view
->in_fd < 0 || errno != 0) {
397 __LINE__ - 4
, errno
);
405 ssize_t bytes_read = 0;
427 bytes_read = read(view
->in_fd, buf,
sizeof(buf));
428 if (bytes_read > 0) {
429 if (write(view
->tmp_fd, buf, bytes_read) != bytes_read)
431 }
else if (bytes_read == 0)
436 if (fstat(view
->tmp_fd, &sb) == -1) {
440 __LINE__ - 4
, errno
);
451 waitpid(-1,
nullptr, 0);
456 if (view
->buf == MAP_FAILED) {
471 for (idx = 0; idx <
NMARKS; idx++)
char stdio_names_str[4096]
char * stdio_fdnames(char *, char *)
#define max(a, b)
max macro evaluates two expressions, returning greatest result.
int ui_surface_addwin(UiSurface *s, ss_t w, uint p, uint lines, uint cols, uint y, uint x)
Add a new window to the specified UiSurface.
void ui_render()
Render the UI by updating panels and refreshing the display.
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_addpad(UiSurface *s, ss_t w, uint view_win, uint lines, uint cols, uint begy, uint begx)
Add a new pad to the specified UiSurface.
void ui_surface_destroy(UiSurface *s)
Destroy a UiSurface, cleaning up its windows and panels.
int ui_border_title(UiSurface *sfc, const char *title)
Draw a box with a title around the specified window.
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.
UiSurface * ui_surface_box(UiSurface *parent, uint 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_get_screen_size(uint *lines, uint *cols)
Get the current screen size (number of lines and columns).
int ui_erase()
Erase the entire screen.
UiSurface * ui_surface_new(ss_t w, UiSurface *parent, uint p, uint lines, uint cols, uint y, uint x)
Create a new UI surface with the specified parameters.
int ui_scrollok(UiSurface *s, ss_t w, bool enable)
Enable or disable scrolling for a UiSurface.
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_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.
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 *,...)
ssnprintf was designed to be a safer alternative to snprintf.
int str_to_args(char **, char *, uint)
Converts a string into an array of argument strings.
bool expand_tilde(char *, uint)
Replaces "~/" in string with 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]