initial commit
This commit is contained in:
89
window.c
Normal file
89
window.c
Normal file
@ -0,0 +1,89 @@
|
||||
#include "curses.h"
|
||||
#include <dirent.h>
|
||||
|
||||
extern unsigned int terminal_height;
|
||||
extern unsigned int terminal_width;
|
||||
|
||||
void window_main(WINDOW *win, unsigned int start_y, unsigned int start_x){
|
||||
|
||||
unsigned int local_width;
|
||||
unsigned int local_height;
|
||||
DIR *path = opendir(".");
|
||||
|
||||
//{{{ size & positioning
|
||||
wresize(win, terminal_height, terminal_width/3);
|
||||
getmaxyx(win, local_height, local_width);
|
||||
mvwin(win, start_y, start_x);
|
||||
wclear(win);
|
||||
//}}}
|
||||
|
||||
wmove(win, 0, 0);
|
||||
if (path == NULL) {
|
||||
wprintw(win, "Unable to read directory");
|
||||
} else {
|
||||
int index = 0;
|
||||
struct dirent *entry;
|
||||
while ( entry=readdir(path) ) {
|
||||
if (entry->d_name[0] != '.') {
|
||||
wprintw(win, "%s", entry->d_name);
|
||||
wmove(win, index, 1);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir(path);
|
||||
|
||||
box(win,0,0);
|
||||
wrefresh(win);
|
||||
}
|
||||
void window_left(WINDOW *win, unsigned int start_y, unsigned int start_x){
|
||||
|
||||
unsigned int local_width;
|
||||
unsigned int local_height;
|
||||
DIR *path = opendir("..");
|
||||
|
||||
//{{{ size & positioning
|
||||
wresize(win, terminal_height, terminal_width/3);
|
||||
getmaxyx(win, local_height, local_width);
|
||||
mvwin(win, start_y, start_x);
|
||||
wclear(win);
|
||||
//}}}
|
||||
|
||||
wmove(win, 0, 0);
|
||||
if (path == NULL) {
|
||||
wprintw(win, "Unable to read directory");
|
||||
} else {
|
||||
int index = 0;
|
||||
struct dirent *entry;
|
||||
while ( entry=readdir(path) ) {
|
||||
if (entry->d_name[0] != '.') {
|
||||
wprintw(win, "%s", entry->d_name);
|
||||
wmove(win, index, 1);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir(path);
|
||||
|
||||
|
||||
box(win,0,0);
|
||||
wrefresh(win);
|
||||
}
|
||||
void window_right(WINDOW *win, unsigned int start_y, unsigned int start_x){
|
||||
|
||||
unsigned int local_width;
|
||||
unsigned int local_height;
|
||||
|
||||
//{{{ size & positioning
|
||||
wresize(win, terminal_height, terminal_width/3);
|
||||
getmaxyx(win, local_height, local_width);
|
||||
mvwin(win, start_y, start_x);
|
||||
wclear(win);
|
||||
//}}}
|
||||
|
||||
wmove(win, local_height/2, local_width/2);
|
||||
wprintw(win, "%d,%d", local_height, local_width);
|
||||
|
||||
box(win,0,0);
|
||||
wrefresh(win);
|
||||
}
|
Reference in New Issue
Block a user