summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d5ca1e0)
raw | patch | inline | side by side (parent: d5ca1e0)
author | Kalle Wallin <kaw@linux.se> | |
Mon, 12 Jul 2004 18:03:09 +0000 (18:03 +0000) | ||
committer | Kalle Wallin <kaw@linux.se> | |
Mon, 12 Jul 2004 18:03:09 +0000 (18:03 +0000) |
ChangeLog | patch | blob | history | |
src/list_window.c | patch | blob | history | |
src/list_window.h | patch | blob | history | |
src/screen_help.c | patch | blob | history |
diff --git a/ChangeLog b/ChangeLog
index 31d6508e849844acbb7dd4e3c25272e61fae6baf..0a995d862443f68b08207aef94b4df52a6de097a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
* options.c: fixed short option handling for multiple short options
at once (-abcde)
* conf.c: removed support for the old configuration syntax
+ * list_window.[c.h]: added LW_HIDE_CURSOR_FLAG
+ * screen_help.c: hide cursor on the help screen
2004-07-09 Kalle Wallin <kaw@linux.se>
* ncmpc-0.11.0 released (r1820)
diff --git a/src/list_window.c b/src/list_window.c
index 84c19a1c15be14df06bcec22f93740da48e1f33a..b541ac708f186602d72518917bbe3861fa612b59 100644 (file)
--- a/src/list_window.c
+++ b/src/list_window.c
int i;
int fill = options.wide_cursor;
- while( lw->selected < lw->start )
+ if( lw->flags & LW_HIDE_CURSOR )
{
- lw->start--;
- lw->clear=1;
+ lw->selected = -1;
}
- while( lw->selected >= lw->start+lw->rows )
+ else
{
- lw->start++;
- lw->clear=1;
+ while( lw->selected < lw->start )
+ {
+ lw->start--;
+ lw->clear=1;
+ }
+ while( lw->selected >= lw->start+lw->rows )
+ {
+ lw->start++;
+ lw->clear=1;
+ }
}
for(i=0; i<lw->rows; i++)
diff --git a/src/list_window.h b/src/list_window.h
index 8f82791d13954e35351cae4a6fc8590dbaefacd2..8374e53d7235e781f25f8fef5ea51adacab60062 100644 (file)
--- a/src/list_window.h
+++ b/src/list_window.h
#define LW_ROW(lw) (lw ? lw->selected-lw->start : 0)
+#define LW_HIDE_CURSOR 0x01
+
typedef char * (*list_window_callback_fn_t) (int index,
int *highlight,
void *data);
int xoffset;
int clear;
int repaint;
+ int flags;
} list_window_t;
diff --git a/src/screen_help.c b/src/screen_help.c
index 4d76ffe7fa3b6414d90061cb135827a4a6c9684b..4d1db15940f4a978c3c6e3649b480ba22661618f 100644 (file)
--- a/src/screen_help.c
+++ b/src/screen_help.c
help_init(WINDOW *w, int cols, int rows)
{
lw = list_window_init(w, cols, rows);
+ lw->flags = LW_HIDE_CURSOR;
}
static void
static int
help_cmd(screen_t *screen, mpdclient_t *c, command_t cmd)
{
- int retval;
+ lw->repaint=1;
+ switch(cmd)
+ {
+ case CMD_LIST_NEXT:
+ if( lw->start+lw->rows < help_text_rows )
+ lw->start++;
+ return 1;
+ case CMD_LIST_PREVIOUS:
+ if( lw->start >0 )
+ lw->start--;
+ return 1;
+ case CMD_LIST_FIRST:
+ lw->start = 0;
+ return 1;
+ case CMD_LIST_LAST:
+ lw->start = help_text_rows-lw->rows;
+ if( lw->start<0 )
+ lw->start = 0;
+ return 1;
+ case CMD_LIST_NEXT_PAGE:
+ lw->start = lw->start + lw->rows;
+ if( lw->start+lw->rows >= help_text_rows )
+ lw->start = help_text_rows-lw->rows;
+ if( lw->start<0 )
+ lw->start = 0;
+ return 1;
+ case CMD_LIST_PREVIOUS_PAGE:
+ lw->start = lw->start - lw->rows;
+ if( lw->start<0 )
+ lw->start = 0;
+ return 1;
+ default:
+ break;
+ }
- retval = list_window_cmd(lw, help_text_rows, cmd);
- if( !retval )
- return screen_find(screen, c,
- lw, help_text_rows,
- cmd, list_callback);
+ lw->selected = lw->start+lw->rows;
+ if( screen_find(screen, c,
+ lw, help_text_rows,
+ cmd, list_callback) )
+ {
+ /* center the row */
+ lw->start = lw->selected-(lw->rows/2);
+ if( lw->start+lw->rows > help_text_rows )
+ lw->start = help_text_rows-lw->rows;
+ if( lw->start<0 )
+ lw->start=0;
+ return 1;
+ }
- return retval;
+ return 0;
}
static list_window_t *