ui: file list (not finished)
This commit is contained in:
+1
-8
@@ -3,6 +3,7 @@
|
||||
#include "modals/login_credentials.h"
|
||||
#include "modals/login_option.h"
|
||||
#include "modals/server_message.h"
|
||||
#include "widget/file_list.h"
|
||||
// #include "modals/server_message.h"
|
||||
// #include "action.h"
|
||||
#include <ncurses.h>
|
||||
@@ -111,14 +112,6 @@ void print_bars(app_t *app) {
|
||||
wattroff(app->win, A_REVERSE);
|
||||
}
|
||||
|
||||
void draw_file_list(app_t *app) {
|
||||
WINDOW *win = app->left_win;
|
||||
int sz_y, sz_x;
|
||||
getmaxyx(win, sz_y, sz_x);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void app_refresh(app_t *app) {
|
||||
draw_borders(app);
|
||||
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ typedef struct widget_t {
|
||||
} cur;
|
||||
WINDOW *const *parent_win;
|
||||
struct widget_t *w_parent;
|
||||
enum rsize rsize;
|
||||
// enum rsize rsize;
|
||||
void (*callback)(callback_args_t *args);
|
||||
} widget_t;
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
#include "file_list.h"
|
||||
#include <ncurses.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
file_list_t *init_file_list(WINDOW **win) {
|
||||
file_list_t *fl_ui = malloc(sizeof(file_list_t));
|
||||
init_widget(&(fl_ui->w), NULL, win,"");
|
||||
return fl_ui;
|
||||
}
|
||||
|
||||
void draw_file_list(file_list_t *fl_ui, fl_item_t **fl_start) {
|
||||
int32_t sz_y, sz_x;
|
||||
int32_t p_y, p_x;
|
||||
getmaxyx(*(fl_ui->w.parent_win), sz_y, sz_x);
|
||||
p_y = 1;
|
||||
p_x = 1;
|
||||
fl_item_t *el = *fl_start;
|
||||
|
||||
do {
|
||||
p_x = 1;
|
||||
mvwprintw(*(fl_ui->w.parent_win), p_y, p_x, "%s%n", el->name, &p_x);
|
||||
for (uint i = 1; p_x < sz_x; i++) {
|
||||
mvwprintw(*(fl_ui->w.parent_win), p_y, ++p_x, " ");
|
||||
}
|
||||
p_y++;
|
||||
} while ((el = el->next) != NULL && p_y < sz_y);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
#ifndef FILE_LIST_H
|
||||
#define FILE_LIST_H
|
||||
#include "../widget.h"
|
||||
#include <stdint.h>
|
||||
typedef struct {
|
||||
widget_t w;
|
||||
fl_item_t *current;
|
||||
fl_item_t *start;
|
||||
int32_t current_idx;
|
||||
} file_list_t;
|
||||
|
||||
void draw_file_list(file_list_t *fl_ui, fl_item_t **fl_start);
|
||||
file_list_t *init_file_list(WINDOW **win);
|
||||
#endif
|
||||
Reference in New Issue
Block a user