aboutsummaryrefslogtreecommitdiff
path: root/tsalis
diff options
context:
space:
mode:
authorPaul Oliver <contact@pauloliver.dev>2024-02-29 01:50:45 +0100
committerPaul Oliver <contact@pauloliver.dev>2024-02-29 01:50:45 +0100
commite070c5fe084d181654e8090d6e5ee1faef873060 (patch)
treeb142f319f21b76f4d1f0824fb84551a164cf3a5b /tsalis
parentcbabefebf76a7c288648752812e87bd41999757f (diff)
Updated plugins. Added fast-scroll command.
Diffstat (limited to 'tsalis')
-rw-r--r--tsalis/include/printer.h2
-rw-r--r--tsalis/src/handler.c8
-rw-r--r--tsalis/src/printer.c67
3 files changed, 65 insertions, 12 deletions
diff --git a/tsalis/include/printer.h b/tsalis/include/printer.h
index f5d8c3c..4430e88 100644
--- a/tsalis/include/printer.h
+++ b/tsalis/include/printer.h
@@ -20,6 +20,8 @@ void tsp_prevPage (void);
void tsp_nextPage (void);
void tsp_scrollUp (void);
void tsp_scrollDown (void);
+void tsp_fastScrollUp (void);
+void tsp_fastScrollDown (void);
void tsp_scrollLeft (void);
void tsp_scrollRight (void);
void tsp_scrollToTop (void);
diff --git a/tsalis/src/handler.c b/tsalis/src/handler.c
index f5be2c8..b1dae89 100644
--- a/tsalis/src/handler.c
+++ b/tsalis/src/handler.c
@@ -240,6 +240,14 @@ tsh_handleEvent(int event)
tsp_scrollRight();
break;
+ case 'W':
+ tsp_fastScrollDown();
+ break;
+
+ case 'S':
+ tsp_fastScrollUp();
+ break;
+
case 'Q':
tsp_scrollToTop();
break;
diff --git a/tsalis/src/printer.c b/tsalis/src/printer.c
index 88da4a8..c835f24 100644
--- a/tsalis/src/printer.c
+++ b/tsalis/src/printer.c
@@ -5,6 +5,8 @@
#include "printer.h"
#include "tsalis.h"
+#define PROC_PAGE_LINES_BEFORE_LIST 16
+
enum {
PAIR_NORMAL = 1,
PAIR_HEADER = 2,
@@ -111,18 +113,6 @@ tsp_init(void)
curs_set(0);
keypad(stdscr, TRUE);
start_color();
-
- if (can_change_color()) {
- init_color(COLOR_BLACK, 0, 0, 0);
- init_color(COLOR_RED, 700, 0, 0);
- init_color(COLOR_GREEN, 0, 700, 0);
- init_color(COLOR_YELLOW, 700, 700, 0);
- init_color(COLOR_BLUE, 0, 0, 700);
- init_color(COLOR_MAGENTA, 700, 0, 700);
- init_color(COLOR_CYAN, 0, 700, 700);
- init_color(COLOR_WHITE, 700, 700, 700);
- }
-
init_pair(PAIR_NORMAL, COLOR_WHITE, COLOR_BLACK);
init_pair(PAIR_HEADER, COLOR_CYAN, COLOR_BLACK);
init_pair(PAIR_SELECTED_PROC, COLOR_YELLOW, COLOR_BLACK);
@@ -213,6 +203,59 @@ tsp_scrollDown(void)
}
void
+tsp_fastScrollUp(void)
+{
+ switch (g_currentPage) {
+ case PAGE_PROCESS: {
+ sword toScroll = LINES - PROC_PAGE_LINES_BEFORE_LIST;
+
+ if (g_processVertScroll >= toScroll) {
+ g_processVertScroll -= toScroll;
+ } else {
+ g_processVertScroll = 0;
+ }
+ }
+
+ break;
+
+ case PAGE_WORLD:
+ if (g_worldPos >= g_worldArea) {
+ g_worldPos -= g_worldArea;
+ } else {
+ g_worldPos = 0;
+ }
+
+ break;
+ }
+
+ refresh();
+}
+
+void
+tsp_fastScrollDown(void)
+{
+ switch (g_currentPage) {
+ case PAGE_PROCESS: {
+ sword toScroll = LINES - PROC_PAGE_LINES_BEFORE_LIST;
+
+ if (g_processVertScroll < (sp_getCap() - toScroll)) {
+ g_processVertScroll += toScroll;
+ }
+ }
+
+ break;
+
+ case PAGE_WORLD:
+ if ((g_worldPos + g_worldArea) < sm_getSize()) {
+ g_worldPos += g_worldArea;
+ }
+
+ break;
+ }
+
+}
+
+void
tsp_scrollLeft(void)
{
switch (g_currentPage) {