UI: separates app module, fixes in file lists
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
## Current:
|
## Current:
|
||||||
- [ ] Separate common structures in the common.h
|
- [ ] Separate common structures in the common.h
|
||||||
- [ ] Bottom panel attach to the windows
|
- [ ] Fix sizes in upload window
|
||||||
- [ ] Testing
|
- [ ] Testing
|
||||||
- [ ] Sorting in the file list
|
- [ ] Sorting in the file list
|
||||||
- [ ] File upload multiline description (window)
|
- [ ] File upload multiline description (window)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* SPDX-License-Identifier: MIT */
|
/* SPDX-License-Identifier: MIT */
|
||||||
/* Copyright (c) 2026 Oleksandr Zhylin */
|
/* Copyright (c) 2026 Oleksandr Zhylin */
|
||||||
|
|
||||||
#include "app.h"
|
#include "../app.h"
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#include <ncursesw/ncurses.h>
|
#include <ncursesw/ncurses.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
@@ -14,13 +14,13 @@
|
|||||||
|
|
||||||
void ac_file(WINDOW *win, int is_action_w);
|
void ac_file(WINDOW *win, int is_action_w);
|
||||||
|
|
||||||
w_app_t *w_app_init() {
|
app_t *app_init() {
|
||||||
/* get values from terminal size */
|
/* get values from terminal size */
|
||||||
int32_t y_max, x_max;
|
int32_t y_max, x_max;
|
||||||
getmaxyx(stdscr, y_max, x_max);
|
getmaxyx(stdscr, y_max, x_max);
|
||||||
|
|
||||||
/* allocate app struct memory */
|
/* allocate app struct memory */
|
||||||
w_app_t *_app = calloc(1, sizeof(w_app_t));
|
app_t *_app = calloc(1, sizeof(app_t));
|
||||||
|
|
||||||
/* associate values for screen size */
|
/* associate values for screen size */
|
||||||
_app->coordinates.max_x = _app->coordinates.cur_x = x_max;
|
_app->coordinates.max_x = _app->coordinates.cur_x = x_max;
|
||||||
@@ -34,10 +34,10 @@ w_app_t *w_app_init() {
|
|||||||
|
|
||||||
/* print top and bottom bars */
|
/* print top and bottom bars */
|
||||||
_app->main_ui.b_keys_len = 0;
|
_app->main_ui.b_keys_len = 0;
|
||||||
w_app_draw_bars(_app);
|
app_draw_bars(_app);
|
||||||
|
|
||||||
/* here goes box borders */
|
/* here goes box borders */
|
||||||
w_app_draw_borders(_app);
|
app_draw_borders(_app);
|
||||||
|
|
||||||
/* NULL to main_ui */
|
/* NULL to main_ui */
|
||||||
MAIN_UI_RESET(_app);
|
MAIN_UI_RESET(_app);
|
||||||
@@ -51,7 +51,7 @@ w_app_t *w_app_init() {
|
|||||||
return _app;
|
return _app;
|
||||||
}
|
}
|
||||||
|
|
||||||
void w_app_init_nc() {
|
void app_init_nc() {
|
||||||
initscr();
|
initscr();
|
||||||
cbreak();
|
cbreak();
|
||||||
keypad(stdscr, TRUE);
|
keypad(stdscr, TRUE);
|
||||||
@@ -71,7 +71,7 @@ void w_app_init_nc() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void w_app_draw_borders(w_app_t *app) {
|
void app_draw_borders(app_t *app) {
|
||||||
if (app->modal.win != NULL && !app->modal.needs_update) {
|
if (app->modal.win != NULL && !app->modal.needs_update) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -93,9 +93,9 @@ int64_t print_bottom_menu_option(WINDOW *win, char *key, char *title, int64_t y,
|
|||||||
return key_len + title_len;
|
return key_len + title_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
void w_app_draw_bbar(w_app_t *app);
|
void app_draw_bbar(app_t *app);
|
||||||
|
|
||||||
void w_app_draw_bars(w_app_t *app) {
|
void app_draw_bars(app_t *app) {
|
||||||
char top_text[64] = "Hello!";
|
char top_text[64] = "Hello!";
|
||||||
|
|
||||||
wattrset(app->win, A_REVERSE);
|
wattrset(app->win, A_REVERSE);
|
||||||
@@ -119,11 +119,11 @@ void w_app_draw_bars(w_app_t *app) {
|
|||||||
|
|
||||||
/* add content to the bottom bar */
|
/* add content to the bottom bar */
|
||||||
if (app->main_ui.b_keys_len > 0) {
|
if (app->main_ui.b_keys_len > 0) {
|
||||||
w_app_draw_bbar(app);
|
app_draw_bbar(app);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void w_app_draw_bbar(w_app_t *app) {
|
void app_draw_bbar(app_t *app) {
|
||||||
wattrset(app->win, A_REVERSE);
|
wattrset(app->win, A_REVERSE);
|
||||||
int t_margin = 0; /* tab margin */
|
int t_margin = 0; /* tab margin */
|
||||||
int c_size =
|
int c_size =
|
||||||
@@ -150,8 +150,8 @@ void w_app_draw_bbar(w_app_t *app) {
|
|||||||
wattroff(app->win, A_REVERSE);
|
wattroff(app->win, A_REVERSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void w_app_refresh(w_app_t *app) {
|
void app_refresh(app_t *app) {
|
||||||
w_app_draw_borders(app);
|
app_draw_borders(app);
|
||||||
wnoutrefresh(app->win);
|
wnoutrefresh(app->win);
|
||||||
if (app->modal.win != NULL) {
|
if (app->modal.win != NULL) {
|
||||||
if (app->modal.is_initiated != 0) {
|
if (app->modal.is_initiated != 0) {
|
||||||
@@ -164,7 +164,7 @@ void w_app_refresh(w_app_t *app) {
|
|||||||
doupdate();
|
doupdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void w_app_destroy(w_app_t *app, int32_t exit_code) {
|
void app_destroy(app_t *app, int32_t exit_code) {
|
||||||
delwin(app->win);
|
delwin(app->win);
|
||||||
endwin();
|
endwin();
|
||||||
app->win = NULL;
|
app->win = NULL;
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
/* SPDX-License-Identifier: MIT */
|
/* SPDX-License-Identifier: MIT */
|
||||||
/* Copyright (c) 2026 Oleksandr Zhylin */
|
/* Copyright (c) 2026 Oleksandr Zhylin */
|
||||||
|
|
||||||
#ifndef W_APP_H
|
#ifndef APP_H
|
||||||
#define W_APP_H
|
#define APP_H
|
||||||
|
|
||||||
#include "../main.h"
|
#include "../main.h"
|
||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
modal_color_pair = 3,
|
modal_color_pair = 3,
|
||||||
} w_app_color;
|
} app_color;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
WINDOW *win;
|
WINDOW *win;
|
||||||
@@ -25,15 +25,15 @@ typedef struct {
|
|||||||
void (*active_callback)(w_cb_args_t *args);
|
void (*active_callback)(w_cb_args_t *args);
|
||||||
void *active_widget;
|
void *active_widget;
|
||||||
main_window_t main_ui;
|
main_window_t main_ui;
|
||||||
} w_app_t;
|
} app_t;
|
||||||
|
|
||||||
w_app_t *w_app_init(void);
|
app_t *app_init(void);
|
||||||
void w_app_init_nc(void);
|
void app_init_nc(void);
|
||||||
void w_app_destroy(w_app_t *app, int32_t exit_code);
|
void app_destroy(app_t *app, int32_t exit_code);
|
||||||
void w_app_draw_borders(w_app_t *app);
|
void app_draw_borders(app_t *app);
|
||||||
void w_app_draw_bars(w_app_t *app);
|
void app_draw_bars(app_t *app);
|
||||||
void w_app_refresh(w_app_t *app);
|
void app_refresh(app_t *app);
|
||||||
void w_app_draw_modal(w_app_t *app);
|
void app_draw_modal(app_t *app);
|
||||||
void w_app_draw_bbar(w_app_t *app);
|
void app_draw_bbar(app_t *app);
|
||||||
|
|
||||||
#endif // N_APP_H
|
#endif // N_APP_H
|
||||||
+3
-3
@@ -15,7 +15,7 @@
|
|||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
void connect_to_server(w_app_t *app) {
|
void connect_to_server(app_t *app) {
|
||||||
struct sockaddr_in server;
|
struct sockaddr_in server;
|
||||||
server.sin_family = AF_INET;
|
server.sin_family = AF_INET;
|
||||||
server.sin_addr.s_addr = app->params->addr;
|
server.sin_addr.s_addr = app->params->addr;
|
||||||
@@ -23,10 +23,10 @@ void connect_to_server(w_app_t *app) {
|
|||||||
if (-1 ==
|
if (-1 ==
|
||||||
connect(app->params->sd, (struct sockaddr *)&server, sizeof(server))) {
|
connect(app->params->sd, (struct sockaddr *)&server, sizeof(server))) {
|
||||||
perror("connect");
|
perror("connect");
|
||||||
w_app_destroy(app, 2);
|
app_destroy(app, 2);
|
||||||
}
|
}
|
||||||
app->params->is_connected = TRUE;
|
app->params->is_connected = TRUE;
|
||||||
w_app_draw_bars(app);
|
app_draw_bars(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
void init_params(params_t *params) {
|
void init_params(params_t *params) {
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@
|
|||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include <widget.h>
|
#include <widget.h>
|
||||||
|
|
||||||
void connect_to_server(w_app_t *params);
|
void connect_to_server(app_t *params);
|
||||||
void init_params(params_t *restrict);
|
void init_params(params_t *restrict);
|
||||||
void clear_params(params_t *params);
|
void clear_params(params_t *params);
|
||||||
void get_ip_port(params_t *params, char *ip, char *port);
|
void get_ip_port(params_t *params, char *ip, char *port);
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
#include <widget.h>
|
#include <widget.h>
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
void w_app_draw_modal(w_app_t *app) {
|
void app_draw_modal(app_t *app) {
|
||||||
if (app->modal.needs_destroy ||
|
if (app->modal.needs_destroy ||
|
||||||
(app->query_args->state == S_WAIT_SERVER && app->modal.is_initiated)) {
|
(app->query_args->state == S_WAIT_SERVER && app->modal.is_initiated)) {
|
||||||
w_dialogue_destroy(&(app->modal), app);
|
w_dialogue_destroy(&(app->modal), app);
|
||||||
|
|||||||
+9
-10
@@ -16,25 +16,25 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "app.h"
|
#include "../app.h"
|
||||||
#include "connection.h"
|
#include "connection.h"
|
||||||
#include "file_list.h"
|
#include "file_list.h"
|
||||||
#include "query.h"
|
#include "query.h"
|
||||||
|
|
||||||
uint32_t m_id = 0;
|
uint32_t m_id = 0;
|
||||||
|
|
||||||
int32_t process_user_input(w_app_t *app, w_cb_args_t *d_args);
|
int32_t process_user_input(app_t *app, w_cb_args_t *d_args);
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
w_app_t *app;
|
app_t *app;
|
||||||
params_t params;
|
params_t params;
|
||||||
query_args_t *q_args = malloc(sizeof(query_args_t));
|
query_args_t *q_args = malloc(sizeof(query_args_t));
|
||||||
|
|
||||||
app = calloc(1, sizeof(w_app_t));
|
app = calloc(1, sizeof(app_t));
|
||||||
|
|
||||||
w_app_init_nc();
|
app_init_nc();
|
||||||
|
|
||||||
app = w_app_init();
|
app = app_init();
|
||||||
init_params(¶ms);
|
init_params(¶ms);
|
||||||
app->params = ¶ms;
|
app->params = ¶ms;
|
||||||
analyze_args(argc, argv, ¶ms);
|
analyze_args(argc, argv, ¶ms);
|
||||||
@@ -47,7 +47,6 @@ int main(int argc, char **argv) {
|
|||||||
app->query_args = q_args;
|
app->query_args = q_args;
|
||||||
|
|
||||||
main_window_set(app, mw_fl_server);
|
main_window_set(app, mw_fl_server);
|
||||||
main_window_draw(app);
|
|
||||||
|
|
||||||
/* init client to connect to the server */
|
/* init client to connect to the server */
|
||||||
app->params->sd = init_client();
|
app->params->sd = init_client();
|
||||||
@@ -64,18 +63,18 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
query_loop(app);
|
query_loop(app);
|
||||||
clear_params(¶ms);
|
clear_params(¶ms);
|
||||||
w_app_destroy(app, 0);
|
app_destroy(app, 0);
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t process_user_input(w_app_t *app, w_cb_args_t *d_args) {
|
int32_t process_user_input(app_t *app, w_cb_args_t *d_args) {
|
||||||
int32_t c;
|
int32_t c;
|
||||||
w_ui_file_list_t *fui = (w_ui_file_list_t *)app->query_args->main_ui->ui;
|
w_ui_file_list_t *fui = (w_ui_file_list_t *)app->query_args->main_ui->ui;
|
||||||
c = wgetch(app->win);
|
c = wgetch(app->win);
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case KEY_F(9):
|
case KEY_F(9):
|
||||||
w_app_destroy(app, 0);
|
app_destroy(app, 0);
|
||||||
return OK;
|
return OK;
|
||||||
case 'U':
|
case 'U':
|
||||||
case 'u':
|
case 'u':
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ typedef struct {
|
|||||||
|
|
||||||
void asa_modal_dialogue_callback(w_cb_args_t *args) {
|
void asa_modal_dialogue_callback(w_cb_args_t *args) {
|
||||||
w_cb_args_t d_args;
|
w_cb_args_t d_args;
|
||||||
w_app_t *app = args->app;
|
app_t *app = args->app;
|
||||||
w_dialogue_t *d = (w_dialogue_t *)app->active_widget;
|
w_dialogue_t *d = (w_dialogue_t *)app->active_widget;
|
||||||
memcpy(&d_args, args, sizeof(w_cb_args_t));
|
memcpy(&d_args, args, sizeof(w_cb_args_t));
|
||||||
d_args.app = NULL;
|
d_args.app = NULL;
|
||||||
@@ -30,12 +30,12 @@ void asa_modal_dialogue_callback(w_cb_args_t *args) {
|
|||||||
app->query_args->state = S_WAIT_SERVER;
|
app->query_args->state = S_WAIT_SERVER;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
w_app_destroy(app, 0);
|
app_destroy(app, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
w_dialogue_t *m_asa_init(w_app_t *app) {
|
w_dialogue_t *m_asa_init(app_t *app) {
|
||||||
if (app == NULL)
|
if (app == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
w_group_el_init_t content[] = {
|
w_group_el_init_t content[] = {
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
|
|
||||||
#include <widget.h>
|
#include <widget.h>
|
||||||
|
|
||||||
w_dialogue_t *m_asa_init(w_app_t *app);
|
w_dialogue_t *m_asa_init(app_t *app);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -8,7 +8,7 @@ void dwn_pr_modal_cb(w_cb_args_t *args) {
|
|||||||
/* TODO: cancel action */
|
/* TODO: cancel action */
|
||||||
}
|
}
|
||||||
|
|
||||||
w_dialogue_t *m_load_pr_init(w_app_t *app, bool is_upload) {
|
w_dialogue_t *m_load_pr_init(app_t *app, bool is_upload) {
|
||||||
if (app == NULL)
|
if (app == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
w_group_el_init_t content[] = {
|
w_group_el_init_t content[] = {
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
|
|
||||||
#include <widget.h>
|
#include <widget.h>
|
||||||
|
|
||||||
w_dialogue_t *m_load_pr_init(w_app_t *app, bool is_upload);
|
w_dialogue_t *m_load_pr_init(app_t *app, bool is_upload);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -15,7 +15,7 @@ typedef struct {
|
|||||||
|
|
||||||
void init_login_credentials_modal_cb(w_cb_args_t *args) {
|
void init_login_credentials_modal_cb(w_cb_args_t *args) {
|
||||||
w_cb_args_t d_args;
|
w_cb_args_t d_args;
|
||||||
w_app_t *app = args->app;
|
app_t *app = args->app;
|
||||||
w_dialogue_t *d = (w_dialogue_t *)app->active_widget;
|
w_dialogue_t *d = (w_dialogue_t *)app->active_widget;
|
||||||
memcpy(&d_args, args, sizeof(w_cb_args_t));
|
memcpy(&d_args, args, sizeof(w_cb_args_t));
|
||||||
d_args.app = NULL;
|
d_args.app = NULL;
|
||||||
@@ -35,7 +35,7 @@ void init_login_credentials_modal_cb(w_cb_args_t *args) {
|
|||||||
server_send_string(app->query_args, app->params->uname);
|
server_send_string(app->query_args, app->params->uname);
|
||||||
app->query_args->state = S_WAIT_SERVER;
|
app->query_args->state = S_WAIT_SERVER;
|
||||||
d->needs_destroy = true;
|
d->needs_destroy = true;
|
||||||
w_app_draw_bars(app);
|
app_draw_bars(app);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
app->query_args->state = S_ASK_LOGIN_TYPE;
|
app->query_args->state = S_ASK_LOGIN_TYPE;
|
||||||
@@ -44,7 +44,7 @@ void init_login_credentials_modal_cb(w_cb_args_t *args) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
w_dialogue_t *m_login_credentials_init(w_app_t *app) {
|
w_dialogue_t *m_login_credentials_init(app_t *app) {
|
||||||
if (app == NULL)
|
if (app == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
w_group_el_init_t content[] = {
|
w_group_el_init_t content[] = {
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
|
|
||||||
#include <widget.h>
|
#include <widget.h>
|
||||||
|
|
||||||
w_dialogue_t *m_login_credentials_init(w_app_t *app);
|
w_dialogue_t *m_login_credentials_init(app_t *app);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -15,7 +15,7 @@ typedef struct {
|
|||||||
|
|
||||||
void login_modal_option_cb(w_cb_args_t *args) {
|
void login_modal_option_cb(w_cb_args_t *args) {
|
||||||
w_cb_args_t d_args;
|
w_cb_args_t d_args;
|
||||||
w_app_t *app = args->app;
|
app_t *app = args->app;
|
||||||
w_dialogue_t *d = (w_dialogue_t *)app->active_widget;
|
w_dialogue_t *d = (w_dialogue_t *)app->active_widget;
|
||||||
memcpy(&d_args, args, sizeof(w_cb_args_t));
|
memcpy(&d_args, args, sizeof(w_cb_args_t));
|
||||||
d_args.app = NULL;
|
d_args.app = NULL;
|
||||||
@@ -29,7 +29,7 @@ void login_modal_option_cb(w_cb_args_t *args) {
|
|||||||
strcpy(app->params->uname, "anonymous");
|
strcpy(app->params->uname, "anonymous");
|
||||||
server_send_string(app->query_args, app->params->uname);
|
server_send_string(app->query_args, app->params->uname);
|
||||||
app->query_args->state = S_WAIT_SERVER;
|
app->query_args->state = S_WAIT_SERVER;
|
||||||
w_app_draw_bars(app);
|
app_draw_bars(app);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
d->needs_destroy = true;
|
d->needs_destroy = true;
|
||||||
@@ -43,7 +43,7 @@ void login_modal_option_cb(w_cb_args_t *args) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
w_dialogue_t *m_login_option_init(w_app_t *app) {
|
w_dialogue_t *m_login_option_init(app_t *app) {
|
||||||
if (app == NULL)
|
if (app == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
w_group_el_init_t children[] = {{.type = w_button, .label = "Anonymous", .val.num = 1},
|
w_group_el_init_t children[] = {{.type = w_button, .label = "Anonymous", .val.num = 1},
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
|
|
||||||
#include <widget.h>
|
#include <widget.h>
|
||||||
|
|
||||||
w_dialogue_t *m_login_option_init(w_app_t *app);
|
w_dialogue_t *m_login_option_init(app_t *app);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -13,7 +13,7 @@ typedef struct {
|
|||||||
|
|
||||||
void init_notification_modal_cb(w_cb_args_t *args) {
|
void init_notification_modal_cb(w_cb_args_t *args) {
|
||||||
w_cb_args_t d_args;
|
w_cb_args_t d_args;
|
||||||
w_app_t *app = args->app;
|
app_t *app = args->app;
|
||||||
w_dialogue_t *d = (w_dialogue_t *)app->active_widget;
|
w_dialogue_t *d = (w_dialogue_t *)app->active_widget;
|
||||||
memcpy(&d_args, args, sizeof(w_cb_args_t));
|
memcpy(&d_args, args, sizeof(w_cb_args_t));
|
||||||
d_args.app = NULL;
|
d_args.app = NULL;
|
||||||
@@ -24,7 +24,7 @@ void init_notification_modal_cb(w_cb_args_t *args) {
|
|||||||
d->needs_destroy = true;
|
d->needs_destroy = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
w_dialogue_t *m_notification_init(w_app_t *app) {
|
w_dialogue_t *m_notification_init(app_t *app) {
|
||||||
if (app == NULL)
|
if (app == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
|
|
||||||
#include <widget.h>
|
#include <widget.h>
|
||||||
|
|
||||||
w_dialogue_t *m_notification_init(w_app_t *app);
|
w_dialogue_t *m_notification_init(app_t *app);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -17,7 +17,7 @@ typedef struct {
|
|||||||
|
|
||||||
void init_register_modal_cb(w_cb_args_t *args) {
|
void init_register_modal_cb(w_cb_args_t *args) {
|
||||||
w_cb_args_t d_args;
|
w_cb_args_t d_args;
|
||||||
w_app_t *app = args->app;
|
app_t *app = args->app;
|
||||||
w_dialogue_t *d = (w_dialogue_t *)app->active_widget;
|
w_dialogue_t *d = (w_dialogue_t *)app->active_widget;
|
||||||
memcpy(&d_args, args, sizeof(w_cb_args_t));
|
memcpy(&d_args, args, sizeof(w_cb_args_t));
|
||||||
d_args.app = NULL;
|
d_args.app = NULL;
|
||||||
@@ -70,7 +70,7 @@ void init_register_modal_cb(w_cb_args_t *args) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
w_dialogue_t *m_register_init(w_app_t *app) {
|
w_dialogue_t *m_register_init(app_t *app) {
|
||||||
if (app == NULL)
|
if (app == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
|
|
||||||
#include <widget.h>
|
#include <widget.h>
|
||||||
|
|
||||||
w_dialogue_t *m_register_init(w_app_t *app);
|
w_dialogue_t *m_register_init(app_t *app);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -13,7 +13,7 @@ typedef struct {
|
|||||||
|
|
||||||
void server_message_modal_cb(w_cb_args_t *args) {
|
void server_message_modal_cb(w_cb_args_t *args) {
|
||||||
w_cb_args_t d_args;
|
w_cb_args_t d_args;
|
||||||
w_app_t *app = args->app;
|
app_t *app = args->app;
|
||||||
w_dialogue_t *d = (w_dialogue_t *)app->active_widget;
|
w_dialogue_t *d = (w_dialogue_t *)app->active_widget;
|
||||||
memcpy(&d_args, args, sizeof(w_cb_args_t));
|
memcpy(&d_args, args, sizeof(w_cb_args_t));
|
||||||
d_args.app = NULL;
|
d_args.app = NULL;
|
||||||
@@ -34,7 +34,7 @@ void server_message_modal_cb(w_cb_args_t *args) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void *m_server_message_init(w_app_t *app) {
|
void *m_server_message_init(app_t *app) {
|
||||||
if (app == NULL)
|
if (app == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
w_group_el_init_t children[] = {
|
w_group_el_init_t children[] = {
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
|
|
||||||
#include <widget.h>
|
#include <widget.h>
|
||||||
|
|
||||||
void *m_server_message_init(w_app_t *app);
|
void *m_server_message_init(app_t *app);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
void upload_dialogue_modal_cb(w_cb_args_t *args) {
|
void upload_dialogue_modal_cb(w_cb_args_t *args) {
|
||||||
w_cb_args_t d_args;
|
w_cb_args_t d_args;
|
||||||
w_app_t *app = args->app;
|
app_t *app = args->app;
|
||||||
w_dialogue_t *d = (w_dialogue_t *)app->active_widget;
|
w_dialogue_t *d = (w_dialogue_t *)app->active_widget;
|
||||||
memcpy(&d_args, args, sizeof(w_cb_args_t));
|
memcpy(&d_args, args, sizeof(w_cb_args_t));
|
||||||
d_args.app = NULL;
|
d_args.app = NULL;
|
||||||
@@ -33,7 +33,7 @@ void upload_dialogue_modal_cb(w_cb_args_t *args) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
w_dialogue_t *m_upload_dialogue_init(w_app_t *app) {
|
w_dialogue_t *m_upload_dialogue_init(app_t *app) {
|
||||||
if (app == NULL)
|
if (app == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
w_group_el_init_t content[] = {
|
w_group_el_init_t content[] = {
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
|
|
||||||
#include <widget.h>
|
#include <widget.h>
|
||||||
|
|
||||||
w_dialogue_t *m_upload_dialogue_init(w_app_t *app);
|
w_dialogue_t *m_upload_dialogue_init(app_t *app);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
void upload_props_dialogue_modal_cb(w_cb_args_t *args) {
|
void upload_props_dialogue_modal_cb(w_cb_args_t *args) {
|
||||||
w_cb_args_t d_args;
|
w_cb_args_t d_args;
|
||||||
w_app_t *app = args->app;
|
app_t *app = args->app;
|
||||||
w_dialogue_t *d = (w_dialogue_t *)app->active_widget;
|
w_dialogue_t *d = (w_dialogue_t *)app->active_widget;
|
||||||
memcpy(&d_args, args, sizeof(w_cb_args_t));
|
memcpy(&d_args, args, sizeof(w_cb_args_t));
|
||||||
d_args.app = NULL;
|
d_args.app = NULL;
|
||||||
@@ -57,7 +57,7 @@ void upload_props_dialogue_modal_cb(w_cb_args_t *args) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
w_dialogue_t *m_upload_props_dialogue_init(w_app_t *app) {
|
w_dialogue_t *m_upload_props_dialogue_init(app_t *app) {
|
||||||
if (app == NULL)
|
if (app == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
w_group_el_init_t content[] = {{.type = w_checkbox,
|
w_group_el_init_t content[] = {{.type = w_checkbox,
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
|
|
||||||
#include <widget.h>
|
#include <widget.h>
|
||||||
|
|
||||||
w_dialogue_t *m_upload_props_dialogue_init(w_app_t *app);
|
w_dialogue_t *m_upload_props_dialogue_init(app_t *app);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
+11
-10
@@ -33,19 +33,19 @@
|
|||||||
#include "server.h"
|
#include "server.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
static int process_command(w_app_t *app, wait_server_cb *cb);
|
static int process_command(app_t *app, wait_server_cb *cb);
|
||||||
void user_request_description(query_args_t *q_args);
|
void user_request_description(query_args_t *q_args);
|
||||||
int process_query(w_app_t *app);
|
int process_query(app_t *app);
|
||||||
int32_t process_user_input(w_app_t *app, w_cb_args_t *d_args);
|
int32_t process_user_input(app_t *app, w_cb_args_t *d_args);
|
||||||
|
|
||||||
#define EXIT_APP(message, app, exit_code) \
|
#define EXIT_APP(message, app, exit_code) \
|
||||||
{ \
|
{ \
|
||||||
w_alert(message); \
|
w_alert(message); \
|
||||||
close_session(app->params->sd); \
|
close_session(app->params->sd); \
|
||||||
w_app_destroy(app, exit_code); \
|
app_destroy(app, exit_code); \
|
||||||
}
|
}
|
||||||
|
|
||||||
void query_loop(w_app_t *app) {
|
void query_loop(app_t *app) {
|
||||||
query_args_t *query_args = app->query_args;
|
query_args_t *query_args = app->query_args;
|
||||||
fd_set readfds;
|
fd_set readfds;
|
||||||
int32_t sd = app->params->sd;
|
int32_t sd = app->params->sd;
|
||||||
@@ -61,8 +61,9 @@ void query_loop(w_app_t *app) {
|
|||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
/* update screen */
|
/* update screen */
|
||||||
w_app_draw_modal(app);
|
app_draw_modal(app);
|
||||||
w_app_refresh(app);
|
main_window_draw(app);
|
||||||
|
app_refresh(app);
|
||||||
|
|
||||||
FD_ZERO(&readfds);
|
FD_ZERO(&readfds);
|
||||||
FD_SET(STDIN_FILENO, &readfds);
|
FD_SET(STDIN_FILENO, &readfds);
|
||||||
@@ -135,7 +136,7 @@ void wait_register(query_args_t *q_args) {
|
|||||||
email);
|
email);
|
||||||
}
|
}
|
||||||
|
|
||||||
int upload_confirm_cb(w_app_t *app, char *query, int q_len) {
|
int upload_confirm_cb(app_t *app, char *query, int q_len) {
|
||||||
if (!strncmp("finished\n", query, sizeof("finished\n") - 1)) {
|
if (!strncmp("finished\n", query, sizeof("finished\n") - 1)) {
|
||||||
w_ui_file_list_t *fui = (w_ui_file_list_t *)app->query_args->main_ui->ui;
|
w_ui_file_list_t *fui = (w_ui_file_list_t *)app->query_args->main_ui->ui;
|
||||||
w_notification("File upload", dc_normal,
|
w_notification("File upload", dc_normal,
|
||||||
@@ -151,7 +152,7 @@ int upload_confirm_cb(w_app_t *app, char *query, int q_len) {
|
|||||||
return 1; /* TODO: Error case */
|
return 1; /* TODO: Error case */
|
||||||
}
|
}
|
||||||
|
|
||||||
int process_query(w_app_t *app) {
|
int process_query(app_t *app) {
|
||||||
query_args_t *query_args = app->query_args;
|
query_args_t *query_args = app->query_args;
|
||||||
file_args_t *file_args = app->file_args;
|
file_args_t *file_args = app->file_args;
|
||||||
query_args->buf[query_args->buf_used] = 0;
|
query_args->buf[query_args->buf_used] = 0;
|
||||||
@@ -259,7 +260,7 @@ void query_return_to_buf(char *buf, int *buf_used, char *input_line) {
|
|||||||
buf[*buf_used] = 0;
|
buf[*buf_used] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int process_command(w_app_t *app, wait_server_cb *callback) {
|
static int process_command(app_t *app, wait_server_cb *callback) {
|
||||||
query_args_t *q_args = app->query_args;
|
query_args_t *q_args = app->query_args;
|
||||||
int qlen;
|
int qlen;
|
||||||
char *query = NULL;
|
char *query = NULL;
|
||||||
|
|||||||
+4
-4
@@ -4,15 +4,15 @@
|
|||||||
#ifndef QUERY_H
|
#ifndef QUERY_H
|
||||||
#define QUERY_H
|
#define QUERY_H
|
||||||
|
|
||||||
#include "app.h"
|
#include "../app.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include <widget.h>
|
#include <widget.h>
|
||||||
|
|
||||||
void query_loop(w_app_t *);
|
void query_loop(app_t *);
|
||||||
void wait_register(query_args_t *q_args);
|
void wait_register(query_args_t *q_args);
|
||||||
int process_query(w_app_t *app);
|
int process_query(app_t *app);
|
||||||
int query_extract_from_buf(char *buf, int *buf_used, char **output_line);
|
int query_extract_from_buf(char *buf, int *buf_used, char **output_line);
|
||||||
void init_query_args(query_args_t *q_args, params_t *params);
|
void init_query_args(query_args_t *q_args, params_t *params);
|
||||||
typedef int wait_server_cb(w_app_t *app, char *query, int q_len);
|
typedef int wait_server_cb(app_t *app, char *query, int q_len);
|
||||||
void query_return_to_buf(char *buf, int *buf_used, char *input_line);
|
void query_return_to_buf(char *buf, int *buf_used, char *input_line);
|
||||||
#endif
|
#endif
|
||||||
+5
-5
@@ -1,7 +1,7 @@
|
|||||||
/* SPDX-License-Identifier: MIT */
|
/* SPDX-License-Identifier: MIT */
|
||||||
/* Copyright (c) 2026 Oleksandr Zhylin */
|
/* Copyright (c) 2026 Oleksandr Zhylin */
|
||||||
|
|
||||||
#include "app.h"
|
#include "../app.h"
|
||||||
#include "dialogue.h"
|
#include "dialogue.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "query.h"
|
#include "query.h"
|
||||||
@@ -33,7 +33,7 @@ void server_send_string(query_args_t *q, const char *fmt, ...) {
|
|||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
int server_wait_reg_confirm_cb(w_app_t *app, char *line, int l_len) {
|
int server_wait_reg_confirm_cb(app_t *app, char *line, int l_len) {
|
||||||
query_args_t *q_args = app->query_args;
|
query_args_t *q_args = app->query_args;
|
||||||
char query[INBUFSIZE];
|
char query[INBUFSIZE];
|
||||||
w_ui_file_list_t *fui = (w_ui_file_list_t *)q_args->main_ui->ui;
|
w_ui_file_list_t *fui = (w_ui_file_list_t *)q_args->main_ui->ui;
|
||||||
@@ -48,7 +48,7 @@ int server_wait_reg_confirm_cb(w_app_t *app, char *line, int l_len) {
|
|||||||
"Welcome, %s!",
|
"Welcome, %s!",
|
||||||
app->params->uname);
|
app->params->uname);
|
||||||
w_notification("Registration", dc_normal, query);
|
w_notification("Registration", dc_normal, query);
|
||||||
w_app_draw_bars(app);
|
app_draw_bars(app);
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
q_args->state = S_ASK_REGISTER;
|
q_args->state = S_ASK_REGISTER;
|
||||||
@@ -57,7 +57,7 @@ int server_wait_reg_confirm_cb(w_app_t *app, char *line, int l_len) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int server_print_message_cb(w_app_t *app, char *line, int l_len) {
|
int server_print_message_cb(app_t *app, char *line, int l_len) {
|
||||||
int64_t new_capacity;
|
int64_t new_capacity;
|
||||||
query_args_t *q_args = app->query_args;
|
query_args_t *q_args = app->query_args;
|
||||||
if (q_args->server_message.text == NULL) {
|
if (q_args->server_message.text == NULL) {
|
||||||
@@ -93,7 +93,7 @@ int server_print_message_cb(w_app_t *app, char *line, int l_len) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int process_server_command(char *line, int l_len, w_app_t *app) {
|
int process_server_command(char *line, int l_len, app_t *app) {
|
||||||
int ws_pos = l_len;
|
int ws_pos = l_len;
|
||||||
query_args_t *q_args = app->query_args;
|
query_args_t *q_args = app->query_args;
|
||||||
params_t *params = q_args->params;
|
params_t *params = q_args->params;
|
||||||
|
|||||||
+4
-4
@@ -4,11 +4,11 @@
|
|||||||
#ifndef SERVER_H
|
#ifndef SERVER_H
|
||||||
#define SERVER_H
|
#define SERVER_H
|
||||||
|
|
||||||
#include "app.h"
|
#include "../app.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
int process_server_command(char *line, int l_len, w_app_t *app);
|
int process_server_command(char *line, int l_len, app_t *app);
|
||||||
void ask_register(params_t *params, char *email);
|
void ask_register(params_t *params, char *email);
|
||||||
void server_send_string(query_args_t *q, const char *fmt, ...);
|
void server_send_string(query_args_t *q, const char *fmt, ...);
|
||||||
int server_print_message_cb(w_app_t *app, char *line, int l_len);
|
int server_print_message_cb(app_t *app, char *line, int l_len);
|
||||||
int server_wait_reg_confirm_cb(w_app_t *app, char *line, int l_len);
|
int server_wait_reg_confirm_cb(app_t *app, char *line, int l_len);
|
||||||
#endif
|
#endif
|
||||||
+3
-3
@@ -7,13 +7,13 @@
|
|||||||
|
|
||||||
/* Short notifications. Prefer using this method to simply notify the client */
|
/* Short notifications. Prefer using this method to simply notify the client */
|
||||||
|
|
||||||
static w_app_t *app;
|
static app_t *app;
|
||||||
|
|
||||||
void alert_cb(w_cb_args_t *args) {
|
void alert_cb(w_cb_args_t *args) {
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
void w_alert_init(w_app_t *_app) { app = _app; }
|
void w_alert_init(app_t *_app) { app = _app; }
|
||||||
|
|
||||||
void w_alert(const char *message) { w_notification("Alert", dc_alert, message); }
|
void w_alert(const char *message) { w_notification("Alert", dc_alert, message); }
|
||||||
|
|
||||||
@@ -54,7 +54,7 @@ void w_notification(const char *title, enum w_dialogue_color_scheme color,
|
|||||||
delwin(d->win);
|
delwin(d->win);
|
||||||
free(d);
|
free(d);
|
||||||
app->active_callback = callback;
|
app->active_callback = callback;
|
||||||
w_app_refresh(app);
|
app_refresh(app);
|
||||||
if (app->modal.win != NULL) {
|
if (app->modal.win != NULL) {
|
||||||
app->modal.needs_update = true;
|
app->modal.needs_update = true;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -1,10 +1,10 @@
|
|||||||
#ifndef W_ALERT_H
|
#ifndef W_ALERT_H
|
||||||
#define W_ALERT_H
|
#define W_ALERT_H
|
||||||
|
|
||||||
#include "app.h"
|
#include "../app.h"
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
void w_alert_init(w_app_t *app);
|
void w_alert_init(app_t *app);
|
||||||
void w_alert(const char *message);
|
void w_alert(const char *message);
|
||||||
void w_notification(const char *title, enum w_dialogue_color_scheme color,
|
void w_notification(const char *title, enum w_dialogue_color_scheme color,
|
||||||
const char *f_message, ...);
|
const char *f_message, ...);
|
||||||
|
|||||||
+1
-1
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
#include <widget_core.h>
|
#include <widget_core.h>
|
||||||
#include "button.h"
|
#include "button.h"
|
||||||
#include "app.h"
|
#include "../app.h"
|
||||||
|
|
||||||
w_button_t *init_button(WINDOW **win, w_t *w_parent, char *label) {
|
w_button_t *init_button(WINDOW **win, w_t *w_parent, char *label) {
|
||||||
w_button_t *btn = malloc(sizeof(w_button_t));
|
w_button_t *btn = malloc(sizeof(w_button_t));
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "app.h"
|
#include "../app.h"
|
||||||
#include "checkbox.h"
|
#include "checkbox.h"
|
||||||
#include <widget_core.h>
|
#include <widget_core.h>
|
||||||
|
|
||||||
|
|||||||
@@ -301,7 +301,7 @@ int32_t w_dialogue_draw(w_dialogue_t *d) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void w_dialogue_destroy(w_dialogue_t *d, void *_app) {
|
void w_dialogue_destroy(w_dialogue_t *d, void *_app) {
|
||||||
w_app_t *app = (w_app_t *)_app;
|
app_t *app = (app_t *)_app;
|
||||||
if (d->g_content) {
|
if (d->g_content) {
|
||||||
w_group_destroy(d->g_content);
|
w_group_destroy(d->g_content);
|
||||||
}
|
}
|
||||||
@@ -315,5 +315,5 @@ void w_dialogue_destroy(w_dialogue_t *d, void *_app) {
|
|||||||
app->active_callback = (w_cb_t)app->main_ui.cb_b_press;
|
app->active_callback = (w_cb_t)app->main_ui.cb_b_press;
|
||||||
app->query_args->active_dialogue = NULL;
|
app->query_args->active_dialogue = NULL;
|
||||||
u_d_arr_ptr_free(&(d->id_map));
|
u_d_arr_ptr_free(&(d->id_map));
|
||||||
w_app_refresh(app);
|
app_refresh(app);
|
||||||
}
|
}
|
||||||
+1
-1
@@ -6,7 +6,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "app.h"
|
#include "../app.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include <widget_core.h>
|
#include <widget_core.h>
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
/* Copyright (c) 2026 Oleksandr Zhylin */
|
/* Copyright (c) 2026 Oleksandr Zhylin */
|
||||||
|
|
||||||
#include "progress_bar.h"
|
#include "progress_bar.h"
|
||||||
#include "app.h"
|
#include "../app.h"
|
||||||
#include <ncursesw/ncurses.h>
|
#include <ncursesw/ncurses.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
#ifndef WIDGET_H
|
#ifndef WIDGET_H
|
||||||
#define WIDGET_H
|
#define WIDGET_H
|
||||||
|
|
||||||
#include "app.h"
|
|
||||||
#include "button.h"
|
#include "button.h"
|
||||||
#include "dialogue.h"
|
#include "dialogue.h"
|
||||||
#include "group.h"
|
#include "group.h"
|
||||||
|
|||||||
+13
-14
@@ -1,7 +1,12 @@
|
|||||||
/* SPDX-License-Identifier: MIT */
|
/* SPDX-License-Identifier: MIT */
|
||||||
/* Copyright (c) 2026 Oleksandr Zhylin */
|
/* Copyright (c) 2026 Oleksandr Zhylin */
|
||||||
|
|
||||||
#include "app.h"
|
#include "file_list.h"
|
||||||
|
#include "../app.h"
|
||||||
|
#include "../file_processor.h"
|
||||||
|
#include "../fs.h"
|
||||||
|
#include "../server.h"
|
||||||
|
#include "main_window.h"
|
||||||
#include <bstrlib.h>
|
#include <bstrlib.h>
|
||||||
#include <ncursesw/ncurses.h>
|
#include <ncursesw/ncurses.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
@@ -11,16 +16,11 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "main_window.h"
|
|
||||||
#include "file_list.h"
|
|
||||||
#include "../file_processor.h"
|
|
||||||
#include "../fs.h"
|
|
||||||
#include "../server.h"
|
|
||||||
|
|
||||||
void w_fl_reset(w_ui_file_list_t *fl_ui);
|
void w_fl_reset(w_ui_file_list_t *fl_ui);
|
||||||
|
|
||||||
static void w_fl_cb(w_cb_args_t *args) {
|
static void w_fl_cb(w_cb_args_t *args) {
|
||||||
w_app_t *app = args->app;
|
app_t *app = args->app;
|
||||||
w_ui_file_list_t *fui = app->query_args->main_ui->ui;
|
w_ui_file_list_t *fui = app->query_args->main_ui->ui;
|
||||||
int32_t key = *((int32_t *)args->data);
|
int32_t key = *((int32_t *)args->data);
|
||||||
char q_prefix[128];
|
char q_prefix[128];
|
||||||
@@ -117,7 +117,7 @@ static void w_fl_cb(w_cb_args_t *args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void w_fl_cb_refresh(void *data) {
|
static void w_fl_cb_refresh(void *data) {
|
||||||
w_app_t *app = (w_app_t *)data;
|
app_t *app = (app_t *)data;
|
||||||
if (app->main_ui.type != mw_fl_server) {
|
if (app->main_ui.type != mw_fl_server) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -133,20 +133,19 @@ static struct action_key action_keys[] = {
|
|||||||
{.key = "F9", .title = "Quit", .code = KEY_F(9)},
|
{.key = "F9", .title = "Quit", .code = KEY_F(9)},
|
||||||
};
|
};
|
||||||
|
|
||||||
static int32_t process_user_input(w_app_t *app, w_cb_args_t *d_args) {
|
static int32_t process_user_input(app_t *app, w_cb_args_t *d_args) {
|
||||||
int32_t c;
|
int32_t c;
|
||||||
w_ui_file_list_t *fui = (w_ui_file_list_t *)app->query_args->main_ui->ui;
|
w_ui_file_list_t *fui = (w_ui_file_list_t *)app->query_args->main_ui->ui;
|
||||||
c = wgetch(app->win);
|
c = wgetch(app->win);
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case KEY_F(9):
|
case KEY_F(9):
|
||||||
w_app_destroy(app, 0);
|
app_destroy(app, 0);
|
||||||
return OK;
|
return OK;
|
||||||
case 'U':
|
case 'U':
|
||||||
case 'u':
|
case 'u':
|
||||||
if (!app->modal.is_initiated && !fui->active_search) {
|
if (!app->modal.is_initiated && !fui->active_search) {
|
||||||
/* app->query_args->state = S_UPLOAD_FILE_SELECT; */
|
/* app->query_args->state = S_UPLOAD_FILE_SELECT; */
|
||||||
main_window_set(app, mw_fl_local);
|
main_window_set(app, mw_fl_local);
|
||||||
main_window_draw(app);
|
|
||||||
d_args->element = app->main_ui.ui;
|
d_args->element = app->main_ui.ui;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -165,14 +164,14 @@ static int32_t process_user_input(w_app_t *app, w_cb_args_t *d_args) {
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *w_fl_init(w_app_t *app) {
|
void *w_fl_init(app_t *app) {
|
||||||
w_ui_file_list_t *fui = malloc(sizeof(w_ui_file_list_t));
|
w_ui_file_list_t *fui = malloc(sizeof(w_ui_file_list_t));
|
||||||
app->main_ui.ui = fui;
|
app->main_ui.ui = fui;
|
||||||
app->main_ui.type = mw_fl_server;
|
app->main_ui.type = mw_fl_server;
|
||||||
app->main_ui.cb_refresh = w_fl_cb_refresh;
|
app->main_ui.cb_refresh = w_fl_cb_refresh;
|
||||||
app->main_ui.b_keys = action_keys;
|
app->main_ui.b_keys = action_keys;
|
||||||
app->main_ui.b_keys_len = 4;
|
app->main_ui.b_keys_len = 4;
|
||||||
app->main_ui.cb_b_press = (w_cb_press_t) process_user_input;
|
app->main_ui.cb_b_press = (w_cb_press_t)process_user_input;
|
||||||
app->active_callback = w_fl_cb;
|
app->active_callback = w_fl_cb;
|
||||||
w_init(&(fui->w), NULL, &(app->win), "");
|
w_init(&(fui->w), NULL, &(app->win), "");
|
||||||
WINDOW *win_parent = app->win;
|
WINDOW *win_parent = app->win;
|
||||||
@@ -245,7 +244,7 @@ void w_fl_draw(w_ui_file_list_t *fui) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (fui->activate_last) {
|
if (fui->activate_last) {
|
||||||
fui->current_idx = fui->current_count - 1;
|
fui->current_idx = fui->max_lines - 1;
|
||||||
fui->activate_last = false;
|
fui->activate_last = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
#ifndef W_FILE_LIST_H
|
#ifndef W_FILE_LIST_H
|
||||||
#define W_FILE_LIST_H
|
#define W_FILE_LIST_H
|
||||||
|
|
||||||
#include "app.h"
|
#include "../app.h"
|
||||||
#include <bstrlib.h>
|
#include <bstrlib.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <widget_core.h>
|
#include <widget_core.h>
|
||||||
@@ -27,7 +27,7 @@ typedef struct {
|
|||||||
} w_ui_file_list_t;
|
} w_ui_file_list_t;
|
||||||
|
|
||||||
void w_fl_draw(w_ui_file_list_t *fl_ui);
|
void w_fl_draw(w_ui_file_list_t *fl_ui);
|
||||||
void *w_fl_init(w_app_t *app);
|
void *w_fl_init(app_t *app);
|
||||||
void w_fl_reset(w_ui_file_list_t *fl_ui);
|
void w_fl_reset(w_ui_file_list_t *fl_ui);
|
||||||
void w_fl_destroy(w_ui_file_list_t **fui);
|
void w_fl_destroy(w_ui_file_list_t **fui);
|
||||||
|
|
||||||
|
|||||||
@@ -276,7 +276,7 @@ w_lfl_ui_t *w_lfl_init(WINDOW **win, w_t *w_parent) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void w_lfl_cb_refresh(void *data) {
|
static void w_lfl_cb_refresh(void *data) {
|
||||||
w_app_t *app = (w_app_t *)data;
|
app_t *app = (app_t *)data;
|
||||||
if (app->main_ui.type != mw_fl_local) {
|
if (app->main_ui.type != mw_fl_local) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -290,22 +290,21 @@ static struct action_key action_keys[] = {
|
|||||||
{.key = "F9", .title = "Quit", .code = KEY_F(9)},
|
{.key = "F9", .title = "Quit", .code = KEY_F(9)},
|
||||||
};
|
};
|
||||||
|
|
||||||
static int32_t process_user_input(w_app_t *app, w_cb_args_t *d_args) {
|
static int32_t process_user_input(app_t *app, w_cb_args_t *d_args) {
|
||||||
int32_t c;
|
int32_t c;
|
||||||
w_lfl_ui_t *fui = (w_lfl_ui_t *)app->query_args->main_ui->ui;
|
w_lfl_ui_t *fui = (w_lfl_ui_t *)app->query_args->main_ui->ui;
|
||||||
c = wgetch(app->win);
|
c = wgetch(app->win);
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case KEY_F(9):
|
case KEY_F(9):
|
||||||
w_app_destroy(app, 0);
|
app_destroy(app, 0);
|
||||||
return OK;
|
return OK;
|
||||||
case 'D':
|
case 'D':
|
||||||
case 'd':
|
case 'd':
|
||||||
case '\33': /* ESC key */
|
case '\33': /* ESC key */
|
||||||
if (!app->modal.is_initiated) {
|
if (!app->modal.is_initiated) {
|
||||||
main_window_set(app, mw_fl_server);
|
server_send_string(app->query_args, "file list %u %u\n", fui->max_lines-1,
|
||||||
main_window_draw(app);
|
|
||||||
server_send_string(app->query_args, "file list %u %u\n", fui->max_lines,
|
|
||||||
1);
|
1);
|
||||||
|
main_window_set(app, mw_fl_server);
|
||||||
d_args->element = app->main_ui.ui;
|
d_args->element = app->main_ui.ui;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -317,7 +316,7 @@ static int32_t process_user_input(w_app_t *app, w_cb_args_t *d_args) {
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
w_lfl_ui_t *w_lfl_init_win(w_app_t *app) {
|
w_lfl_ui_t *w_lfl_init_win(app_t *app) {
|
||||||
w_lfl_ui_t *fui = malloc(sizeof(w_lfl_ui_t));
|
w_lfl_ui_t *fui = malloc(sizeof(w_lfl_ui_t));
|
||||||
app->main_ui.ui = fui;
|
app->main_ui.ui = fui;
|
||||||
app->main_ui.type = mw_fl_local;
|
app->main_ui.type = mw_fl_local;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
#ifndef W_LFL_H /* LOCAL FILE LIST */
|
#ifndef W_LFL_H /* LOCAL FILE LIST */
|
||||||
#define W_LFL_H
|
#define W_LFL_H
|
||||||
|
|
||||||
#include "app.h"
|
#include "../app.h"
|
||||||
#include <widget_core.h>
|
#include <widget_core.h>
|
||||||
#include <ncursesw/ncurses.h>
|
#include <ncursesw/ncurses.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
@@ -37,6 +37,6 @@ void w_lfl_draw(w_lfl_ui_t *fl_ui);
|
|||||||
void w_lfl_destroy(w_lfl_ui_t **fui);
|
void w_lfl_destroy(w_lfl_ui_t **fui);
|
||||||
void w_lfl_reset(w_lfl_ui_t *fl_ui);
|
void w_lfl_reset(w_lfl_ui_t *fl_ui);
|
||||||
w_lfl_ui_t *w_lfl_init(WINDOW **win, w_t *w_parent);
|
w_lfl_ui_t *w_lfl_init(WINDOW **win, w_t *w_parent);
|
||||||
w_lfl_ui_t *w_lfl_init_win(w_app_t *app);
|
w_lfl_ui_t *w_lfl_init_win(app_t *app);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -2,10 +2,10 @@
|
|||||||
/* Copyright (c) 2026 Oleksandr Zhylin */
|
/* Copyright (c) 2026 Oleksandr Zhylin */
|
||||||
|
|
||||||
#include "main_window.h"
|
#include "main_window.h"
|
||||||
#include "fs_file_list.h"
|
|
||||||
#include "file_list.h"
|
#include "file_list.h"
|
||||||
|
#include "fs_file_list.h"
|
||||||
|
|
||||||
void main_window_set(w_app_t *app, enum main_window_type type) {
|
void main_window_set(app_t *app, enum main_window_type type) {
|
||||||
if (app->main_ui.ui != NULL) {
|
if (app->main_ui.ui != NULL) {
|
||||||
main_window_destroy(app);
|
main_window_destroy(app);
|
||||||
}
|
}
|
||||||
@@ -25,7 +25,7 @@ void main_window_set(w_app_t *app, enum main_window_type type) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void main_window_draw(w_app_t *app) {
|
void main_window_draw(app_t *app) {
|
||||||
switch (app->main_ui.type) {
|
switch (app->main_ui.type) {
|
||||||
case mw_fl_server:
|
case mw_fl_server:
|
||||||
w_fl_draw((w_ui_file_list_t *)app->main_ui.ui);
|
w_fl_draw((w_ui_file_list_t *)app->main_ui.ui);
|
||||||
@@ -36,16 +36,17 @@ void main_window_draw(w_app_t *app) {
|
|||||||
case mw_f_desc:
|
case mw_f_desc:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
w_app_draw_bbar(app);
|
app_draw_bbar(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
void main_window_destroy(w_app_t *app) {
|
void main_window_destroy(app_t *app) {
|
||||||
switch (app->main_ui.type) {
|
switch (app->main_ui.type) {
|
||||||
case mw_fl_server:
|
case mw_fl_server:
|
||||||
w_fl_destroy((w_ui_file_list_t **)&(app->main_ui.ui));
|
w_fl_destroy((w_ui_file_list_t **)&(app->main_ui.ui));
|
||||||
break;
|
break;
|
||||||
case mw_fl_local:
|
case mw_fl_local:
|
||||||
w_lfl_destroy((w_lfl_ui_t **)&(app->main_ui.ui));
|
w_lfl_destroy((w_lfl_ui_t **)&(app->main_ui.ui));
|
||||||
|
break;
|
||||||
case mw_f_desc:
|
case mw_f_desc:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,10 +4,10 @@
|
|||||||
#ifndef MAIN_WINDOW_H
|
#ifndef MAIN_WINDOW_H
|
||||||
#define MAIN_WINDOW_H
|
#define MAIN_WINDOW_H
|
||||||
|
|
||||||
#include <widget.h>
|
#include "../app.h"
|
||||||
|
|
||||||
void main_window_set(w_app_t *app, enum main_window_type type);
|
void main_window_set(app_t *app, enum main_window_type type);
|
||||||
void main_window_draw(w_app_t *app);
|
void main_window_draw(app_t *app);
|
||||||
void main_window_destroy(w_app_t *app);
|
void main_window_destroy(app_t *app);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
Reference in New Issue
Block a user