File src/console.h changed (mode: 100644) (index 8ffed34..87f4645) |
... |
... |
void console_draw_lines(long start, long end); |
54 |
54 |
*/ |
*/ |
55 |
55 |
int console_scroll(long delta); |
int console_scroll(long delta); |
56 |
56 |
|
|
|
57 |
|
/** |
|
58 |
|
* Scroll console to an absolute position. |
|
59 |
|
* |
|
60 |
|
* @see window_scroll@window.h |
|
61 |
|
*/ |
|
62 |
|
int console_scroll_to(long position); |
|
63 |
|
|
57 |
64 |
/** |
/** |
58 |
65 |
* Allocate memory for a log line. |
* Allocate memory for a log line. |
59 |
66 |
*/ |
*/ |
File src/input.c changed (mode: 100644) (index 13f48ba..f8a99aa) |
... |
... |
static int input_char_get_movement(int ch) { |
35 |
35 |
return INPUT_MOVEMENT_UP; |
return INPUT_MOVEMENT_UP; |
36 |
36 |
} else if (ch == KEY_DOWN || ch == 'j') { |
} else if (ch == KEY_DOWN || ch == 'j') { |
37 |
37 |
return INPUT_MOVEMENT_DOWN; |
return INPUT_MOVEMENT_DOWN; |
|
38 |
|
} else if (ch == 'G') { |
|
39 |
|
return INPUT_MOVEMENT_END; |
38 |
40 |
} |
} |
39 |
41 |
return INPUT_MOVEMENT_NONE; |
return INPUT_MOVEMENT_NONE; |
40 |
42 |
} |
} |
|
... |
... |
static int input_char_get_action(int ch) { |
46 |
48 |
return INPUT_ACTION_GO; |
return INPUT_ACTION_GO; |
47 |
49 |
} else if (ch == 'q') { |
} else if (ch == 'q') { |
48 |
50 |
return INPUT_ACTION_QUIT; |
return INPUT_ACTION_QUIT; |
49 |
|
} else if (ch == 'g') { |
|
|
51 |
|
} else if (ch == 'g' || ch == 'G') { |
50 |
52 |
return INPUT_ACTION_GO; |
return INPUT_ACTION_GO; |
51 |
53 |
} |
} |
52 |
54 |
return INPUT_ACTION_NONE; |
return INPUT_ACTION_NONE; |
|
... |
... |
command_t * input_get() { |
95 |
97 |
input_command_append_movement(i); |
input_command_append_movement(i); |
96 |
98 |
} |
} |
97 |
99 |
if ((i = input_char_get_action(ch)) != INPUT_ACTION_NONE) { |
if ((i = input_char_get_action(ch)) != INPUT_ACTION_NONE) { |
98 |
|
input_command_append_action(i); |
|
|
100 |
|
if (command.action != INPUT_ACTION_NONE && command.action != i) { |
|
101 |
|
console("Invalid input sequence, resetting."); |
|
102 |
|
input_reset(); |
|
103 |
|
} |
|
104 |
|
if (command.action == INPUT_ACTION_NONE) { |
|
105 |
|
input_command_append_action(i); |
|
106 |
|
} else if (command.movement == INPUT_MOVEMENT_NONE) { |
|
107 |
|
input_command_append_movement(INPUT_MOVEMENT_NA); |
|
108 |
|
} |
99 |
109 |
} |
} |
100 |
110 |
if (input_ready()) { |
if (input_ready()) { |
101 |
111 |
if (command.multiplier == 0) { |
if (command.multiplier == 0) { |
|
... |
... |
int input_handle(command_t * command) { |
116 |
126 |
console_scroll(-command->multiplier); |
console_scroll(-command->multiplier); |
117 |
127 |
} else if (command->movement == INPUT_MOVEMENT_DOWN) { |
} else if (command->movement == INPUT_MOVEMENT_DOWN) { |
118 |
128 |
console_scroll(command->multiplier); |
console_scroll(command->multiplier); |
|
129 |
|
} else if (command->movement == INPUT_MOVEMENT_END) { |
|
130 |
|
console_scroll_to(-1); |
|
131 |
|
return 0; |
|
132 |
|
} else if (command->movement == INPUT_MOVEMENT_NA) { |
|
133 |
|
console_scroll_to(command->multiplier-1); // convert 1-indexed to 0-indexed |
|
134 |
|
return 0; |
119 |
135 |
} |
} |
120 |
136 |
} else { |
} else { |
121 |
137 |
return 0; |
return 0; |
File src/input.h changed (mode: 100644) (index cbd3212..bb02bd8) |
17 |
17 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
18 |
18 |
*/ |
*/ |
19 |
19 |
|
|
20 |
|
#define INPUT_MOVEMENT_NA -1 |
|
|
20 |
|
#define INPUT_MOVEMENT_NA -1 |
21 |
21 |
#define INPUT_MOVEMENT_NONE 0 |
#define INPUT_MOVEMENT_NONE 0 |
22 |
|
#define INPUT_MOVEMENT_UP 1 |
|
|
22 |
|
#define INPUT_MOVEMENT_UP 1 |
23 |
23 |
#define INPUT_MOVEMENT_DOWN 2 |
#define INPUT_MOVEMENT_DOWN 2 |
|
24 |
|
#define INPUT_MOVEMENT_END 3 |
24 |
25 |
|
|
25 |
26 |
#define INPUT_ACTION_NONE 0 |
#define INPUT_ACTION_NONE 0 |
26 |
27 |
#define INPUT_ACTION_QUIT 1 |
#define INPUT_ACTION_QUIT 1 |