加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
key-add-page-up-down-key-response.patch 1.41 KB
一键复制 编辑 原始数据 按行查看 历史
From 10be69aa54764c8314501fd1130d9bf8c9f859f2 Mon Sep 17 00:00:00 2001
From: nocjj <1250062498@qq.com>
Date: Thu, 29 Oct 2020 15:35:37 +0800
Subject: [PATCH 3/8] key: add page up/down key response
Add page up/down key response, move pagesize - 6 for beauty.
Signed-off-by: Jiajun Chen <1250062498@qq.com>
---
src/vmtop.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/src/vmtop.c b/src/vmtop.c
index f4ef9ab..65181a1 100644
--- a/src/vmtop.c
+++ b/src/vmtop.c
@@ -373,6 +373,8 @@ static void show_filter(void)
static void parse_keys(int key)
{
+ int scroll_size = 1;
+
switch (key) {
case 'f': {
show_filter();
@@ -382,17 +384,25 @@ static void parse_keys(int key)
quit_flag = !quit_flag;
break;
}
+ case KEY_NPAGE: {
+ /* move pagesize - 6 for beauty */
+ scroll_size = scr_row_size - 6;
+ }
case KEY_UP: {
int task_num = thread_mode ? get_task_num(&scr_cur) : scr_cur.num;
- begin_task++;
+ begin_task += scroll_size;
if (begin_task > task_num) {
begin_task = task_num;
}
break;
}
+ case KEY_PPAGE: {
+ /* move pagesize - 6 for beauty */
+ scroll_size = scr_row_size - 6;
+ }
case KEY_DOWN: {
- begin_task--;
+ begin_task -= scroll_size;
if (begin_task < 1) {
begin_task = 1;
}
--
2.27.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化