aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorverdant <im@verdant.ee>2026-07-22 22:47:56 +0800
committerverdant <im@verdant.ee>2026-07-22 22:47:56 +0800
commit5656ed2c2f67d95e4373685ffe396be3d217f965 (patch)
tree0a7b91308ed05951842fd2a3c23378e81b3bfa20
parent854998edb8d076ade0ffe8adf710fca1e8239a2b (diff)
downloadsf-5656ed2c2f67d95e4373685ffe396be3d217f965.tar.gz
sf-5656ed2c2f67d95e4373685ffe396be3d217f965.zip
Reformat wm.c wm.h
-rw-r--r--display.c77
-rw-r--r--display.h26
2 files changed, 56 insertions, 47 deletions
diff --git a/display.c b/display.c
index 43865a9..9c16d5e 100644
--- a/display.c
+++ b/display.c
@@ -9,45 +9,52 @@
#include "version.h"
#include "wm.h"
-void color_pair_init() {
- init_pair(COLOR_PAIR_STATUS_BAR, COLOR_BLACK, COLOR_WHITE);
- init_pair(COLOR_PAIR_PROGRESS, COLOR_YELLOW, COLOR_BLUE);
- init_pair(COLOR_PAIR_TEXT_INFO, COLOR_WHITE, COLOR_BLUE);
- init_pair(COLOR_PAIR_FM_DIR, COLOR_CYAN, COLOR_BLUE);
- init_pair(COLOR_PAIR_BORDER, COLOR_WHITE, COLOR_BLUE);
+void color_pair_init()
+{
+ init_pair(COLOR_PAIR_STATUS_BAR, COLOR_BLACK, COLOR_WHITE);
+ init_pair(COLOR_PAIR_PROGRESS, COLOR_YELLOW, COLOR_BLUE);
+ init_pair(COLOR_PAIR_TEXT_INFO, COLOR_WHITE, COLOR_BLUE);
+ init_pair(COLOR_PAIR_FM_HL, COLOR_BLACK, COLOR_WHITE);
+ init_pair(COLOR_PAIR_FM_DIR, COLOR_CYAN, COLOR_BLACK);
+ init_pair(COLOR_PAIR_BORDER, COLOR_WHITE, COLOR_BLUE);
}
-terminal *ncurses_init() {
- initscr();
- raw();
- curs_set(0);
- if (!has_colors()) {
- log_write(LOG_WARN, "Terminal does not support colors");
- }
-
- start_color();
- color_pair_init();
- terminal *t = wm_init();
- return t;
+terminal *ncurses_init()
+{
+ initscr();
+ raw();
+ curs_set(0);
+ if (!has_colors()) {
+ log_write(LOG_WARN, "Terminal does not support colors");
+ }
+
+ start_color();
+ color_pair_init();
+ terminal *t = wm_init();
+ return t;
}
-void draw_stat_bar(terminal *t, const char *sys_version) {
- window *stat_bar =
- wm_create_new_w(t, "stat_bar", 1, t->maxx, t->maxy - 1, 0);
- if (!stat_bar || !stat_bar->win) return;
- wattron(stat_bar->win, COLOR_PAIR(COLOR_PAIR_STATUS_BAR));
- mvwprintw(stat_bar->win, 0, 0, "%*s", t->maxx, "");
- mvwprintw(stat_bar->win, 0, 0, "SF v%s | %s", PROGRAM_VERSION, sys_version);
- wattroff(stat_bar->win, COLOR_PAIR(COLOR_PAIR_STATUS_BAR));
-
- wrefresh(stat_bar->win);
+void draw_stat_bar(terminal *t, const char *sys_version)
+{
+ window *stat_bar =
+ wm_create_new_w(t, "stat_bar", 1, t->maxx, t->maxy - 1, 0);
+ if (!stat_bar || !stat_bar->win)
+ return;
+ wattron(stat_bar->win, COLOR_PAIR(COLOR_PAIR_STATUS_BAR));
+ mvwprintw(stat_bar->win, 0, 0, "%*s", t->maxx, "");
+ mvwprintw(stat_bar->win, 0, 0, "SF v%s | %s", PROGRAM_VERSION,
+ sys_version);
+ wattroff(stat_bar->win, COLOR_PAIR(COLOR_PAIR_STATUS_BAR));
+
+ wrefresh(stat_bar->win);
}
-void wprintw_colorful(WINDOW *w, int attr, const char *format, ...) {
- va_list ap;
- va_start(ap, format);
- wattron(w, COLOR_PAIR(attr));
- vw_printw(w, format, ap);
- wattroff(w, COLOR_PAIR(attr));
- va_end(ap);
+void wprintw_colorful(WINDOW *w, int attr, const char *format, ...)
+{
+ va_list ap;
+ va_start(ap, format);
+ wattron(w, COLOR_PAIR(attr));
+ vw_printw(w, format, ap);
+ wattroff(w, COLOR_PAIR(attr));
+ va_end(ap);
}
diff --git a/display.h b/display.h
index 6cc82f3..56c28f4 100644
--- a/display.h
+++ b/display.h
@@ -10,8 +10,9 @@
#define COLOR_PAIR_STATUS_BAR 1
#define COLOR_PAIR_PROGRESS 2
#define COLOR_PAIR_TEXT_INFO 3
-#define COLOR_PAIR_FM_DIR 4
-#define COLOR_PAIR_BORDER 5
+#define COLOR_PAIR_FM_HL 4
+#define COLOR_PAIR_FM_DIR 5
+#define COLOR_PAIR_BORDER 6
#define STAT_INFO_WIDTH 15
#define BAR_LABEL_WIDTH 7
@@ -22,16 +23,17 @@
void color_pair_init();
terminal *ncurses_init();
-static inline WINDOW *get_root_win(const terminal *t) {
- if (!t) {
- log_write(LOG_ERR, "get_root_win: terminal is NULL");
- return NULL;
- }
- if (t->w_count <= 0 || !t->windows[0]) {
- log_write(LOG_ERR, "get_root_win: windows[0] is not allocated");
- return NULL;
- }
- return t->windows[0]->win;
+static inline WINDOW *get_root_win(const terminal *t)
+{
+ if (!t) {
+ log_write(LOG_ERR, "get_root_win: terminal is NULL");
+ return NULL;
+ }
+ if (t->w_count <= 0 || !t->windows[0]) {
+ log_write(LOG_ERR, "get_root_win: windows[0] is not allocated");
+ return NULL;
+ }
+ return t->windows[0]->win;
}
#define ROOT_WIN get_root_win(t)