Minor improvements, unfinished...
This commit is contained in:
parent
6cf6a35022
commit
19017523c6
38
xource.c
38
xource.c
@ -12,11 +12,11 @@ It is distributed in the hope that it will be useful or harmful, it really depen
|
||||
|
||||
#define CONTROL (0X1F)
|
||||
#define ESCAPE (0X1B)
|
||||
#define BACKSPACE (0X7F)
|
||||
#define ARROW_UP (0X415B1B)
|
||||
#define ARROW_DOWN (0X425B1B)
|
||||
#define ARROW_RIGHT (0X435B1B)
|
||||
#define ARROW_LEFT (0X445B1B)
|
||||
#define BACKSPACE (0X7F)
|
||||
|
||||
int main (int argc, char * * argv) {
|
||||
char * keywords [] = {
|
||||
@ -53,21 +53,29 @@ int main (int argc, char * * argv) {
|
||||
curses_configure ();
|
||||
|
||||
do {
|
||||
int offset, select, length;
|
||||
int offset, select, length, cursor_on_new_line;
|
||||
|
||||
curses_render_background (' ', COLOUR_WHITE, EFFECT_NORMAL);
|
||||
|
||||
length = 0;
|
||||
curses_render_string (file_list_name [file_list_active], COLOUR_WHITE, EFFECT_REVERSE, length, 0);
|
||||
length += string_length (file_list_name [file_list_active]);
|
||||
/* */
|
||||
curses_render_string (" $ ", COLOUR_WHITE, EFFECT_REVERSE, length, 0);
|
||||
length += 3;
|
||||
curses_render_string (number_to_string (file_list_size [file_list_active]), COLOUR_WHITE, EFFECT_REVERSE, length, 0);
|
||||
length += string_length (number_to_string (file_list_size [file_list_active]));
|
||||
/* */
|
||||
curses_render_string (" O ", COLOUR_WHITE, EFFECT_REVERSE, length, 0);
|
||||
length += 3;
|
||||
curses_render_string (number_to_string (cursor), COLOUR_WHITE, EFFECT_REVERSE, length, 0);
|
||||
length += string_length (number_to_string (cursor));
|
||||
/* */
|
||||
curses_render_string (" X ", COLOUR_WHITE, EFFECT_REVERSE, length, 0);
|
||||
length += 3;
|
||||
curses_render_string (number_to_string (cursor_x), COLOUR_WHITE, EFFECT_REVERSE, length, 0);
|
||||
length += string_length (number_to_string (cursor_x));
|
||||
/* */
|
||||
curses_render_string (" Y ", COLOUR_WHITE, EFFECT_REVERSE, length, 0);
|
||||
length += 3;
|
||||
curses_render_string (number_to_string (cursor_y), COLOUR_WHITE, EFFECT_REVERSE, length, 0);
|
||||
@ -81,7 +89,7 @@ int main (int argc, char * * argv) {
|
||||
curses_render_string (string_realign (number_to_string (offset), 4, ' '), COLOUR_WHITE, EFFECT_REVERSE, 0, offset);
|
||||
}
|
||||
|
||||
cursor_x = curses_realign_x = 5;
|
||||
cursor_x = curses_realign_x = 5; /* Border offset... */
|
||||
cursor_y = curses_realign_y = 1;
|
||||
|
||||
for (offset = 0; file_list_data [file_list_active] [offset] != '\0'; offset += length) {
|
||||
@ -104,16 +112,14 @@ int main (int argc, char * * argv) {
|
||||
}
|
||||
}
|
||||
|
||||
cursor_y = character_count (file_list_data [file_list_active], 0, cursor, '\n', '\0');
|
||||
cursor_x = character_count (file_list_data [file_list_active], cursor, 0, '\0', '\n');
|
||||
cursor_on_new_line = (file_list_data [file_list_active] [cursor] == '\n');
|
||||
|
||||
cursor_y = character_count (file_list_data [file_list_active], '\n', 0, cursor + cursor_on_new_line, '\0') - cursor_on_new_line;
|
||||
cursor_x = character_count (file_list_data [file_list_active], '\0', cursor - cursor_on_new_line, 0, '\n') + cursor_on_new_line;
|
||||
/*
|
||||
dump ("a.log", " xx ");
|
||||
dump ("a.log", number_to_string (cursor_x));
|
||||
dump ("a.log", " yy ");
|
||||
dump ("a.log", number_to_string (cursor_y));
|
||||
dump ("a.log", "\n");
|
||||
dump ("a.log", string_concatenate (number_to_string (cursor_x), "\n"));
|
||||
*/
|
||||
curses_render_cursor (cursor_x + curses_realign_x + 1, cursor_y + curses_realign_y + 1);
|
||||
curses_render_cursor (cursor_x + curses_realign_x, cursor_y + curses_realign_y);
|
||||
|
||||
curses_synchronize ();
|
||||
|
||||
@ -128,15 +134,9 @@ int main (int argc, char * * argv) {
|
||||
file_list_remove_character (cursor);
|
||||
--cursor;
|
||||
} else if (curses_character == ARROW_UP) {
|
||||
do {
|
||||
--cursor;
|
||||
} while ((cursor >= 0) && (file_list_data [file_list_active] [cursor] != '\n') && (file_list_data [file_list_active] [cursor] != '\0'));
|
||||
--cursor;
|
||||
cursor -= character_count (file_list_data [file_list_active], '\0', cursor - 1, 0, '\n') - 1;
|
||||
} else if (curses_character == ARROW_DOWN) {
|
||||
do {
|
||||
++cursor;
|
||||
} while ((cursor <= file_list_size [file_list_active] - 1) && (file_list_data [file_list_active] [cursor] != '\n') && (file_list_data [file_list_active] [cursor] != '\0'));
|
||||
++cursor;
|
||||
cursor += character_count (file_list_data [file_list_active], '\0', cursor, file_list_size [file_list_active] - 1, '\n') + 1;
|
||||
} else if (curses_character == ARROW_RIGHT) {
|
||||
++cursor;
|
||||
} else if (curses_character == ARROW_LEFT) {
|
||||
|
Loading…
Reference in New Issue
Block a user