summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 41d5f05)
raw | patch | inline | side by side (parent: 41d5f05)
author | Kalle Wallin <kaw@linux.se> | |
Wed, 21 Apr 2004 19:06:18 +0000 (19:06 +0000) | ||
committer | Kalle Wallin <kaw@linux.se> | |
Wed, 21 Apr 2004 19:06:18 +0000 (19:06 +0000) |
command.c | patch | blob | history | |
main.c | patch | blob | history | |
screen.c | patch | blob | history | |
screen.h | patch | blob | history | |
screen_file.c | patch | blob | history | |
screen_help.c | patch | blob | history | |
screen_keydef.c | patch | blob | history | |
screen_play.c | patch | blob | history | |
screen_utils.c | patch | blob | history |
diff --git a/command.c b/command.c
index 2ad85d0cef4d7406fcc8fa0780f545013f25186b..2a426e347ea85dbe0cf980fb6f098aa7098f9282 100644 (file)
--- a/command.c
+++ b/command.c
key = wgetch(stdscr);
+ if( key==KEY_RESIZE )
+ screen_resize();
+
if( key==ERR )
return CMD_NONE;
index 21fd5ac42f3e3aea0e42ba9d16d7d67f33b4814b..1d458841864ee08b8f187645c6f5754463a85862 100644 (file)
--- a/main.c
+++ b/main.c
perror("signal");
exit(EXIT_FAILURE);
}
- /* setup signal behavior - SIGWINCH */
- sigemptyset( &act.sa_mask );
- act.sa_flags = 0;
- act.sa_handler = screen_resized;
- if( sigaction( SIGWINCH, &act, NULL )<0 )
- {
- perror("sigaction()");
- exit(EXIT_FAILURE);
- }
/* setup signal behavior - SIGTERM */
sigemptyset( &act.sa_mask );
act.sa_flags = 0;
diff --git a/screen.c b/screen.c
index ccf7c8cc71893c9490b2c9bc674a224f0b34878d..53146216c001f37b86725fb656b1a8d0d7cc4e03 100644 (file)
--- a/screen.c
+++ b/screen.c
#include <stdarg.h>
#include <string.h>
#include <time.h>
+#include <signal.h>
#include <glib.h>
#include <ncurses.h>
}
void
-screen_resized(int sig)
+screen_resize(void)
{
- screen_exit();
+ GList *list;
+
+#ifdef DEBUG
+ fprintf(stderr, "Resize rows %d->%d, cols %d->%d\n",
+ screen->rows, LINES,
+ screen->cols, COLS);
+#endif
+
if( COLS<SCREEN_MIN_COLS || LINES<SCREEN_MIN_ROWS )
{
+ screen_exit();
fprintf(stderr, "Error: Screen to small!\n");
exit(EXIT_FAILURE);
}
- screen_init();
+
+ resizeterm(LINES, COLS);
+
+ screen->cols = COLS;
+ screen->rows = LINES;
+
+ /* top window */
+ screen->top_window.cols = screen->cols;
+ wresize(screen->top_window.w, 2, screen->cols);
+
+ /* main window */
+ screen->main_window.cols = screen->cols;
+ screen->main_window.rows = screen->rows-4;
+ wresize(screen->main_window.w, screen->main_window.rows, screen->cols);
+ wclear(screen->main_window.w);
+
+ /* progress window */
+ screen->progress_window.cols = screen->cols;
+ wresize(screen->progress_window.w, 1, screen->cols);
+ mvwin(screen->progress_window.w, screen->rows-2, 0);
+
+ /* status window */
+ screen->status_window.cols = screen->cols;
+ wresize(screen->status_window.w, 1, screen->cols);
+ mvwin(screen->status_window.w, screen->rows-1, 0);
+
+ screen->buf_size = screen->cols;
+ g_free(screen->buf);
+ screen->buf = g_malloc(screen->cols);
+
+ list = g_list_first(screen->screen_list);
+ while( list )
+ {
+ screen_functions_t *mode_fn = list->data;
+
+ if( mode_fn && mode_fn->resize )
+ mode_fn->resize(screen->main_window.cols, screen->main_window.rows);
+
+ list=list->next;
+ }
+
+ screen->painted = 0;
}
void
diff --git a/screen.h b/screen.h
index d770aba0f902aaac706d8d90431dac3a7ca0c6a4..a95269337b8c11bd70bdc527e13b48ecbed90a06 100644 (file)
--- a/screen.h
+++ b/screen.h
typedef void (*screen_exit_fn_t) (void);
typedef void (*screen_open_fn_t) (screen_t *screen, mpd_client_t *c);
typedef void (*screen_close_fn_t) (void);
+typedef void (*screen_resize_fn_t) (int cols, int rows);
typedef void (*screen_paint_fn_t) (screen_t *screen, mpd_client_t *c);
typedef void (*screen_update_fn_t) (screen_t *screen, mpd_client_t *c);
typedef int (*screen_cmd_fn_t) (screen_t *scr, mpd_client_t *c, command_t cmd);
screen_exit_fn_t exit;
screen_open_fn_t open;
screen_close_fn_t close;
+ screen_resize_fn_t resize;
screen_paint_fn_t paint;
screen_update_fn_t update;
screen_cmd_fn_t cmd;
int screen_init(void);
int screen_exit(void);
-void screen_resized(int sig);
+void screen_resize(void);
void screen_status_message(char *msg);
void screen_status_printf(char *format, ...);
char *screen_error(void);
diff --git a/screen_file.c b/screen_file.c
index a0b9ee3f7c6dd87fbdc641c176d7b35c5cfe6898..e57fc317f25d03478f9ff4f643c7d3e13440a1c0 100644 (file)
--- a/screen_file.c
+++ b/screen_file.c
snprintf(buf, BUFSIZE, "Delete playlist %s [y/n] ? ", str);
g_free(str);
key = tolower(screen_getch(screen->status_window.w, buf));
+ if( key==KEY_RESIZE )
+ screen_resize();
if( key!='y' )
{
screen_status_printf("Aborted!");
lw = list_window_init(w, cols, rows);
}
+static void
+file_resize(int cols, int rows)
+{
+ lw->cols = cols;
+ lw->rows = rows;
+}
+
static void
file_exit(void)
{
functions.exit = file_exit;
functions.open = file_open;
functions.close = file_close;
+ functions.resize = file_resize;
functions.paint = file_paint;
functions.update = file_update;
functions.cmd = file_cmd;
diff --git a/screen_help.c b/screen_help.c
index 833342b9d719d50d5195ed30e6146126271bae11..37bf9a385965dc077e20c7b201584807ad013e40 100644 (file)
--- a/screen_help.c
+++ b/screen_help.c
lw = list_window_init(w, cols, rows);
}
+static void
+help_resize(int cols, int rows)
+{
+ lw->cols = cols;
+ lw->rows = rows;
+}
+
static void
help_exit(void)
{
functions.exit = help_exit;
functions.open = NULL;
functions.close = NULL;
+ functions.resize = help_resize;
functions.paint = help_paint;
functions.update = help_update;
functions.cmd = help_cmd;
diff --git a/screen_keydef.c b/screen_keydef.c
index 46510c06b12e339d06200aa5fab8e7aefca819f1..4bda6ea212bbb7869de3717fc0d62cc5427c5f33 100644 (file)
--- a/screen_keydef.c
+++ b/screen_keydef.c
snprintf(buf, BUFSIZE, "Enter new key for %s: ", cmds[cmd_index].name);
key = screen_getch(w, buf);
+ if( key==KEY_RESIZE )
+ screen_resize();
if( key==ERR )
{
screen_status_printf("Aborted!");
lw = list_window_init(w, cols, rows);
}
+static void
+keydef_resize(int cols, int rows)
+{
+ lw->cols = cols;
+ lw->rows = rows;
+}
+
static void
keydef_exit(void)
{
functions.exit = keydef_exit;
functions.open = keydef_open;
functions.close = keydef_close;
+ functions.resize = keydef_resize;
functions.paint = keydef_paint;
functions.update = keydef_update;
functions.cmd = keydef_cmd;
diff --git a/screen_play.c b/screen_play.c
index 5669d36416188bf546f3183490e784fc9e175cba..eb1048951a5081f744bdae0d1427af99313238b5 100644 (file)
--- a/screen_play.c
+++ b/screen_play.c
lw = list_window_init(w, cols, rows);
}
+static void
+play_resize(int cols, int rows)
+{
+ lw->cols = cols;
+ lw->rows = rows;
+}
+
+
static void
play_exit(void)
{
functions.exit = play_exit;
functions.open = NULL;
functions.close = NULL;
+ functions.resize = play_resize;
functions.paint = play_paint;
functions.update = play_update;
functions.cmd = play_cmd;
diff --git a/screen_utils.c b/screen_utils.c
index c9fff74c4b2fe776b5a1b84cf9ae47ec393aad4d..1fb581aaadb87dc9a8aa6018c8b20f0256b9c370 100644 (file)
--- a/screen_utils.c
+++ b/screen_utils.c
timeout(-1);
key = wgetch(w);
+ if( key==KEY_RESIZE )
+ screen_resize();
noecho();
curs_set(0);