ui: file list (not finished)
This commit is contained in:
@@ -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