Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
htop
Commits
0128d222
Commit
0128d222
authored
Jun 15, 2016
by
Hisham
Browse files
Added Ctrl+A and Ctrl+E to go to beginning and end of line.
(Also, '^' and '$') Closes #508.
parent
1a13b4d0
Changes
5
Hide whitespace changes
Inline
Side-by-side
CategoriesPanel.c
View file @
0128d222
...
...
@@ -82,9 +82,9 @@ static HandlerResult CategoriesPanel_eventHandler(Panel* super, int ch) {
result
=
HANDLED
;
break
;
case
KEY_UP
:
case
KEY_CTRL
P
:
case
KEY_CTRL
(
'P'
)
:
case
KEY_DOWN
:
case
KEY_CTRL
N
:
case
KEY_CTRL
(
'N'
)
:
case
KEY_NPAGE
:
case
KEY_PPAGE
:
case
KEY_HOME
:
...
...
MainPanel.c
View file @
0128d222
...
...
@@ -105,20 +105,6 @@ static HandlerResult MainPanel_eventHandler(Panel* super, int ch) {
}
else
{
reaction
|=
HTOP_KEEP_FOLLOWING
;
}
switch
(
ch
)
{
case
KEY_LEFT
:
case
KEY_CTRLB
:
if
(
super
->
scrollH
>
0
)
{
super
->
scrollH
-=
CRT_scrollHAmount
;
super
->
needsRedraw
=
true
;
}
return
HANDLED
;
case
KEY_RIGHT
:
case
KEY_CTRLF
:
super
->
scrollH
+=
CRT_scrollHAmount
;
super
->
needsRedraw
=
true
;
return
HANDLED
;
}
}
if
(
reaction
&
HTOP_REDRAW_BAR
)
{
...
...
Panel.c
View file @
0128d222
...
...
@@ -61,6 +61,7 @@ struct Panel_ {
Vector* items;
int selected;
int oldSelected;
int selectedLen;
void* eventHandlerState;
int scrollV;
short scrollH;
...
...
@@ -82,10 +83,7 @@ struct Panel_ {
#define MAX(a,b) ((a)>(b)?(a):(b))
#endif
#define KEY_CTRLN 0016
/* control-n key */
#define KEY_CTRLP 0020
/* control-p key */
#define KEY_CTRLF 0006
/* control-f key */
#define KEY_CTRLB 0002
/* control-b key */
#define KEY_CTRL(l) ((l)-'A'+1)
PanelClass
Panel_class
=
{
.
super
=
{
...
...
@@ -327,6 +325,7 @@ void Panel_draw(Panel* this, bool focus) {
if
(
selected
)
{
attrset
(
selectionColor
);
RichString_setAttr
(
&
item
,
selectionColor
);
this
->
selectedLen
=
itemLen
;
}
mvhline
(
y
+
line
,
x
,
' '
,
this
->
w
);
if
(
amt
>
0
)
...
...
@@ -352,6 +351,7 @@ void Panel_draw(Panel* this, bool focus) {
RichString_begin
(
new
);
Object_display
(
newObj
,
&
new
);
int
newLen
=
RichString_sizeVal
(
new
);
this
->
selectedLen
=
newLen
;
mvhline
(
y
+
this
->
oldSelected
-
first
,
x
+
0
,
' '
,
this
->
w
);
if
(
scrollH
<
oldLen
)
RichString_printoffnVal
(
old
,
y
+
this
->
oldSelected
-
first
,
x
,
...
...
@@ -376,11 +376,11 @@ bool Panel_onKey(Panel* this, int key) {
int
size
=
Vector_size
(
this
->
items
);
switch
(
key
)
{
case
KEY_DOWN
:
case
KEY_CTRL
N
:
case
KEY_CTRL
(
'N'
)
:
this
->
selected
++
;
break
;
case
KEY_UP
:
case
KEY_CTRL
P
:
case
KEY_CTRL
(
'P'
)
:
this
->
selected
--
;
break
;
#ifdef KEY_C_DOWN
...
...
@@ -394,14 +394,14 @@ bool Panel_onKey(Panel* this, int key) {
break
;
#endif
case
KEY_LEFT
:
case
KEY_CTRL
B
:
case
KEY_CTRL
(
'B'
)
:
if
(
this
->
scrollH
>
0
)
{
this
->
scrollH
-=
CRT_scrollHAmount
;
this
->
scrollH
-=
MAX
(
CRT_scrollHAmount
,
0
)
;
this
->
needsRedraw
=
true
;
}
break
;
case
KEY_RIGHT
:
case
KEY_CTRL
F
:
case
KEY_CTRL
(
'F'
)
:
this
->
scrollH
+=
CRT_scrollHAmount
;
this
->
needsRedraw
=
true
;
break
;
...
...
@@ -436,6 +436,14 @@ bool Panel_onKey(Panel* this, int key) {
case
KEY_END
:
this
->
selected
=
size
-
1
;
break
;
case
KEY_CTRL
(
'A'
):
case
'^'
:
this
->
scrollH
=
0
;
break
;
case
KEY_CTRL
(
'E'
):
case
'$'
:
this
->
scrollH
=
MAX
(
this
->
selectedLen
-
this
->
w
,
0
);
break
;
default:
return
false
;
}
...
...
Panel.h
View file @
0128d222
...
...
@@ -50,6 +50,7 @@ struct Panel_ {
Vector
*
items
;
int
selected
;
int
oldSelected
;
int
selectedLen
;
void
*
eventHandlerState
;
int
scrollV
;
short
scrollH
;
...
...
@@ -70,10 +71,7 @@ struct Panel_ {
#define MAX(a,b) ((a)>(b)?(a):(b))
#endif
#define KEY_CTRLN 0016
/* control-n key */
#define KEY_CTRLP 0020
/* control-p key */
#define KEY_CTRLF 0006
/* control-f key */
#define KEY_CTRLB 0002
/* control-b key */
#define KEY_CTRL(l) ((l)-'A'+1)
extern
PanelClass
Panel_class
;
...
...
ScreenManager.c
View file @
0128d222
...
...
@@ -279,7 +279,10 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
continue
;
}
case
KEY_LEFT
:
case
KEY_CTRLB
:
case
KEY_CTRL
(
'B'
):
if
(
this
->
panelCount
<
2
)
{
goto
defaultHandler
;
}
if
(
!
this
->
allowFocusChange
)
break
;
tryLeft:
...
...
@@ -290,8 +293,11 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
goto
tryLeft
;
break
;
case
KEY_RIGHT
:
case
KEY_CTRL
F
:
case
KEY_CTRL
(
'F'
)
:
case
9
:
if
(
this
->
panelCount
<
2
)
{
goto
defaultHandler
;
}
if
(
!
this
->
allowFocusChange
)
break
;
tryRight:
...
...
@@ -307,6 +313,7 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
quit
=
true
;
continue
;
default:
defaultHandler:
sortTimeout
=
resetSortTimeout
;
Panel_onKey
(
panelFocus
,
ch
);
break
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment