[w3m-dev 03493] scroll menu

* menu.c (mLineU): added
	(mLineD): added
	(MenuKeymap): C-r, C-s, J, K
	(mouse_scroll_line): added
	(process_mMouse): drag
		BTN4, BTN5
* doc-jp/README.menu: update
From: Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
This commit is contained in:
Fumitoshi UKAI
2002-11-27 16:28:36 +00:00
parent 161a0e19c5
commit 25a17ab5ca
3 changed files with 109 additions and 9 deletions

View File

@@ -1,3 +1,14 @@
2002-11-28 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
* [w3m-dev 03493] scroll menu
* menu.c (mLineU): added
(mLineD): added
(MenuKeymap): C-r, C-s, J, K
(mouse_scroll_line): added
(process_mMouse): drag
BTN4, BTN5
* doc-jp/README.menu: update
2002-11-27 Fumitoshi UKAI <ukai@debian.or.jp>
* version.c.in: w3m/0.3.2.1+cvs
@@ -5204,4 +5215,4 @@ a * [w3m-dev 03276] compile error on EWS4800
* release-0-2-1
* import w3m-0.2.1
$Id: ChangeLog,v 1.565 2002/11/27 03:06:04 ukai Exp $
$Id: ChangeLog,v 1.566 2002/11/27 16:28:36 ukai Exp $

View File

@@ -1,6 +1,6 @@
w3m のメニューについて
(1999/11/03) 坂本 浩則
(2002/11/27) 坂本 浩則
hsaka@mth.biglobe.ne.jp
[1] キー操作
@@ -13,10 +13,16 @@ w3m
BS(C-h), DEL(C-?), ←キー : 戻る
C-n, j, ↓キー : 下の項目へ
C-p, k, ↑キー : 上の項目へ
J : 項目を上にスクロール
K : 項目を下にスクロール
C-a : 先頭の項目へ
C-e : 最後の項目へ
C-f, C-v : 次ページの項目へ
C-b, M-v : 前ページの項目へ
C-s, / : 項目を下に向かって検索
C-r, ? : 項目を上に向かって検索
n : 次の項目を検索
N : 前の項目を検索
C-z : サスペンド
# INS は通常 ^[[2~ ですが ^[[L(コンソール), ^[[E(PocketBSD) にも
@@ -41,6 +47,7 @@ w3m
″ (枠外) : 戻る(メニューの消去)
″ ( : ) : 次ページまたは前ページの項目へ
(長いメニューの場合)
″ (ドラッグ) : スクロール
[3] メニューのカスタマイズ
@@ -62,7 +69,7 @@ w3m
例は menu.default や menu.submenu を見てください。
設定できるコマンド(FUNCTION)は README.func を見てください。
MENU_ID として "Main" はメインメニューに、"Select" はバッファ選択
メニューに予約されています。
メニューに、"SelectTab" はタブ選択メニューに予約されています。
KEYS はバインドするキーで複数指定可能です。
DATA が設定されていればコマンド(FUNCTION)の引数として使われます。

94
menu.c
View File

@@ -1,4 +1,4 @@
/* $Id: menu.c,v 1.20 2002/11/25 16:57:17 ukai Exp $ */
/* $Id: menu.c,v 1.21 2002/11/27 16:28:37 ukai Exp $ */
/*
* w3m menu.c
*/
@@ -85,6 +85,8 @@ static int mNext(char c);
static int mPrev(char c);
static int mFore(char c);
static int mBack(char c);
static int mLineU(char c);
static int mLineD(char c);
static int mOk(char c);
static int mCancel(char c);
static int mClose(char c);
@@ -109,7 +111,7 @@ static int (*MenuKeymap[128]) (char c) = {
/* C-h C-i C-j C-k C-l C-m C-n C-o */
mCancel,mNull, mOk, mNull, mNull, mOk, mDown, mNull,
/* C-p C-q C-r C-s C-t C-u C-v C-w */
mUp, mNull, mNull, mNull, mNull, mNull, mNext, mNull,
mUp, mNull, mSrchB, mSrchF, mNull, mNull, mNext, mNull,
/* C-x C-y C-z C-[ C-\ C-] C-^ C-_ */
mNull, mNull, mSusp, mEsc, mNull, mNull, mNull, mNull,
/* SPC ! " # $ % & ' */
@@ -123,7 +125,7 @@ static int (*MenuKeymap[128]) (char c) = {
/* @ A B C D E F G */
mNull, mNull, mNull, mNull, mNull, mNull, mNull, mNull,
/* H I J K L M N O */
mNull, mNull, mNull, mNull, mNull, mNull, mSrchP, mNull,
mNull, mNull, mLineU, mLineD, mNull, mNull, mSrchP, mNull,
/* P Q R S T U V W */
mNull, mNull, mNull, mNull, mNull, mNull, mNull, mNull,
/* X Y Z [ \ ] ^ _ */
@@ -896,6 +898,42 @@ mBack(char c)
return (MENU_NOTHING);
}
static int
mLineU(char c)
{
int mselect = CurrentMenu->select;
if (mselect >= CurrentMenu->nitem)
return mLast(c);
if (CurrentMenu->offset + CurrentMenu->height >= CurrentMenu->nitem)
mselect++;
else {
down_menu(CurrentMenu, 1);
if (mselect < CurrentMenu->offset)
mselect++;
}
goto_menu(CurrentMenu, mselect, 1);
return (MENU_NOTHING);
}
static int
mLineD(char c)
{
int mselect = CurrentMenu->select;
if (mselect <= 0)
return mTop(c);
if (CurrentMenu->offset <= 0)
mselect--;
else {
up_menu(CurrentMenu, 1);
if (mselect >= CurrentMenu->offset + CurrentMenu->height)
mselect--;
}
goto_menu(CurrentMenu, mselect, -1);
return (MENU_NOTHING);
}
static int
mOk(char c)
{
@@ -1086,11 +1124,22 @@ mSrchP(char c)
#define MOUSE_BTN_UP 3
#define MOUSE_BTN_RESET -1
static int
mMouse_scroll_line(void)
{
int i = 0;
if (relative_wheel_scroll)
i = (relative_wheel_scroll_ratio * CurrentMenu->height + 99) / 100;
else
i = fixed_wheel_scroll_count;
return i ? i : 1;
}
static int
process_mMouse(int btn, int x, int y)
{
Menu *menu;
int mselect;
int mselect, i;
static int press_btn = MOUSE_BTN_RESET, press_x, press_y;
char c = ' ';
@@ -1100,7 +1149,9 @@ process_mMouse(int btn, int x, int y)
return (MENU_NOTHING);
if (btn == MOUSE_BTN_UP) {
if (press_btn == MOUSE_BTN1_DOWN || press_btn == MOUSE_BTN3_DOWN) {
switch (press_btn) {
case MOUSE_BTN1_DOWN:
case MOUSE_BTN3_DOWN:
if (x < menu->x - FRAME_WIDTH ||
x >= menu->x + menu->width + FRAME_WIDTH ||
y < menu->y - 1 || y >= menu->y + menu->height + 1) {
@@ -1112,6 +1163,16 @@ process_mMouse(int btn, int x, int y)
x < menu->x + menu->width + FRAME_WIDTH)) {
return (MENU_NOTHING);
}
else if (press_y > y) {
for (i = 0; i < press_y - y; i++)
mLineU(c);
return (MENU_NOTHING);
}
else if (press_y < y) {
for (i = 0; i < y - press_y; i++)
mLineD(c);
return (MENU_NOTHING);
}
else if (y == menu->y - 1) {
mPrev(c);
return (MENU_NOTHING);
@@ -1126,13 +1187,34 @@ process_mMouse(int btn, int x, int y)
return (MENU_NOTHING);
return (select_menu(menu, mselect));
}
break;
case MOUSE_BTN4_DOWN_RXVT:
for (i = 0; i < mMouse_scroll_line(); i++)
mLineD(c);
break;
case MOUSE_BTN5_DOWN_RXVT:
for (i = 0; i < mMouse_scroll_line(); i++)
mLineU(c);
break;
}
}
else {
else if (btn == MOUSE_BTN4_DOWN_XTERM) {
for (i = 0; i < mMouse_scroll_line(); i++)
mLineD(c);
}
else if (btn == MOUSE_BTN5_DOWN_XTERM) {
for (i = 0; i < mMouse_scroll_line(); i++)
mLineU(c);
}
if (btn != MOUSE_BTN4_DOWN_RXVT || press_btn == MOUSE_BTN_RESET) {
press_btn = btn;
press_x = x;
press_y = y;
}
else {
press_btn = MOUSE_BTN_RESET;
}
return (MENU_NOTHING);
}