Skip to contentSkip to conversation

Document key bindings

PATCH In review Hans-Peter Deifel 3 participants 7 messages May 19, 2013 – May 20, 2013

lore
Share & tools
lore

Hans-Peter Deifel

author
#0 lore raw

cover Document key bindings

Hi list,

I had trouble finding all keybindings for powertop and decided to document them better. The first patch makes the code itself more readable, the second one adds a new section about keys to the man page.

Regards,
Hans-Peter

Hans-Peter Deifel (2):
Use symbolic instead of numeric constants for keys Document key bindings in man page

 doc/powertop.8 | 32 ++++++++++++++++++++++++++++++++
 src/main.cpp   | 10 +++++-----
 2 files changed, 37 insertions(+), 5 deletions(-)
Signature · 1 line
1.8.1.5
author
#1 lore raw

PATCH 1/2 Use symbolic instead of numeric constants for keys

This improves the readability of the key handling code.

Since there is no symbolic constant for Escape, a comment with an explanation is added.

Signed-off-by Hans-Peter Deifel <hpdeifel(a)gmx.de>
---
 src/main.cpp | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
src/main.cpp +5 -5
index 0883424..46466b0 100644
@@ -136,10 +136,10 @@ static void do_sleep(int seconds)
 
 		c = getch();
 		switch (c) {
-		case 353: 
+		case KEY_BTAB:
 			show_prev_tab();
 			break;
-		case 9:
+		case '\t':
 			show_next_tab(); 
 			break;
 		case KEY_RIGHT:
@@ -156,8 +156,8 @@ static void do_sleep(int seconds)
 		case KEY_UP:
 			cursor_up();
 			break;
-		case 32:
-		case 10:
+		case ' ':
+		case '\n':
 			cursor_enter();
 			break;
 		case 's':
@@ -169,7 +169,7 @@ static void do_sleep(int seconds)
 			return;
 		case KEY_EXIT:
 		case 'q':
-		case 27:
+		case 27:	// Escape
 			leave_powertop = 1;
 			return;
 		}
Signature · 1 line
1.8.1.5
Acked-by on v1 1/2
#2 lore raw

Re: [Powertop] [PATCH 1/2] Use symbolic instead of numeric constants for keys

Am Sonntag, den 19.05.2013, 18:00 +0200 schrieb Hans-Peter Deifel:

Quoted 9 lines

This improves the readability of the key handling code.

Since there is no symbolic constant for Escape, a comment with an explanation is added.

Signed-off-by Hans-Peter Deifel <hpdeifel(a)gmx.de>
---
 src/main.cpp | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

[…]

Acked-by Paul Menzel <paulepanter(a)users.sourceforge.net>

Thanks,

Paul

#3 lore raw

Re: [Powertop] [PATCH 1/2] Use symbolic instead of numeric constants for keys

In reply to Hans-Peter Deifel
Quoted 7 lines · Hans-Peter Deifel

This improves the readability of the key handling code.

Since there is no symbolic constant for Escape, a comment with an explanation is added.

Signed-off-by Hans-Peter Deifel <hpdeifel(a)gmx.de>

---

looks good, thanks.

	-ss
Quoted 48 lines
 src/main.cpp | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
src/main.cpp +5 -5
index 0883424..46466b0 100644
@@ -136,10 +136,10 @@ static void do_sleep(int seconds)
 
 		c = getch();
 		switch (c) {
-		case 353: 
+		case KEY_BTAB:
 			show_prev_tab();
 			break;
-		case 9:
+		case '\t':
 			show_next_tab(); 
 			break;
 		case KEY_RIGHT:
@@ -156,8 +156,8 @@ static void do_sleep(int seconds)
 		case KEY_UP:
 			cursor_up();
 			break;
-		case 32:
-		case 10:
+		case ' ':
+		case '\n':
 			cursor_enter();
 			break;
 		case 's':
@@ -169,7 +169,7 @@ static void do_sleep(int seconds)
 			return;
 		case KEY_EXIT:
 		case 'q':
-		case 27:
+		case 27:	// Escape
 			leave_powertop = 1;
 			return;
 		}
Signature · 6 lines
1.8.1.5

_______________________________________________
PowerTop mailing list
PowerTop(a)lists.01.org
https://lists.01.org/mailman/listinfo/powertop
author
#4 lore raw

PATCH 2/2 Document key bindings in man page

In reply to Hans-Peter Deifel
Signed-off-by Hans-Peter Deifel <hpdeifel(a)gmx.de>
---
 doc/powertop.8 | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
doc/powertop.8 +32 -0
index 8a70076..e6ec199 100644
@@ -54,6 +54,38 @@ generate a report for a specified number of seconds.
 .TP
 \fB\-\-version
 print version information and exit.
+.SH COMMANDS
+In interactive mode, the following key bindings are available:
+.TP
+\fBTab
+Show next tab
+.TP
+\fBBackTab
+Show previous tab
+.TP
+\fBRight Arrow
+Scroll to the right
+.TP
+\fBLeft Arrow
+Scroll to the left
+.TP
+\fBUp Arrow, PageUp
+Scroll up or select previous item
+.TP
+\fBDown Arrow, PageDown
+Scroll down or select next item
+.TP
+\fBSpace, Return
+Activate current item
+.TP
+\fBs
+Set refresh timeout
+.TP
+\fBr
+Refresh window
+.TP
+\fBq, Ctrl-C, Escape
+Exit powertop
 .SH BUGS
 Send bug reports to <powertop(a)lists.01.org>
 .SH SEE ALSO
Signature · 1 line
1.8.1.5
Acked-by on v1 2/2
#5 lore raw

Re: [Powertop] [PATCH 2/2] Document key bindings in man page

Am Sonntag, den 19.05.2013, 18:00 +0200 schrieb Hans-Peter Deifel:

Quoted 4 lines
Signed-off-by Hans-Peter Deifel <hpdeifel(a)gmx.de>
---
 doc/powertop.8 | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

[…]

Acked-by Paul Menzel <paulepanter(a)users.sourceforge.net>

Thanks,

Paul

#6 lore raw

Re: [Powertop] [PATCH 2/2] Document key bindings in man page

In reply to Hans-Peter Deifel
Quoted 2 lines · Hans-Peter Deifel
Signed-off-by Hans-Peter Deifel <hpdeifel(a)gmx.de>

---

looks good.

	-ss
Quoted 54 lines
 doc/powertop.8 | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
doc/powertop.8 +32 -0
index 8a70076..e6ec199 100644
@@ -54,6 +54,38 @@ generate a report for a specified number of seconds.
 .TP
 \fB\-\-version
 print version information and exit.
+.SH COMMANDS
+In interactive mode, the following key bindings are available:
+.TP
+\fBTab
+Show next tab
+.TP
+\fBBackTab
+Show previous tab
+.TP
+\fBRight Arrow
+Scroll to the right
+.TP
+\fBLeft Arrow
+Scroll to the left
+.TP
+\fBUp Arrow, PageUp
+Scroll up or select previous item
+.TP
+\fBDown Arrow, PageDown
+Scroll down or select next item
+.TP
+\fBSpace, Return
+Activate current item
+.TP
+\fBs
+Set refresh timeout
+.TP
+\fBr
+Refresh window
+.TP
+\fBq, Ctrl-C, Escape
+Exit powertop
 .SH BUGS
 Send bug reports to <powertop(a)lists.01.org>
 .SH SEE ALSO
Signature · 6 lines
1.8.1.5

_______________________________________________
PowerTop mailing list
PowerTop(a)lists.01.org
https://lists.01.org/mailman/listinfo/powertop