summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8e032a1)
raw | patch | inline | side by side (parent: 8e032a1)
author | Kalle Wallin <kaw@linux.se> | |
Tue, 22 Jun 2004 13:25:53 +0000 (13:25 +0000) | ||
committer | Kalle Wallin <kaw@linux.se> | |
Tue, 22 Jun 2004 13:25:53 +0000 (13:25 +0000) |
diff --git a/src/list_window.c b/src/list_window.c
index 588725625c8708d600514ac5da6946e822400c76..84c19a1c15be14df06bcec22f93740da48e1f33a 100644 (file)
--- a/src/list_window.c
+++ b/src/list_window.c
#include "colors.h"
#include "list_window.h"
+extern void screen_bell(void);
+
list_window_t *
list_window_init(WINDOW *w, int width, int height)
{
list_window_t *lw;
- lw = g_malloc(sizeof(list_window_t));
- memset(lw, 0, sizeof(list_window_t));
+ lw = g_malloc0(sizeof(list_window_t));
lw->w = w;
lw->cols = width;
lw->rows = height;
list_window_reset(list_window_t *lw)
{
lw->selected = 0;
+ lw->xoffset = 0;
lw->start = 0;
lw->clear = 1;
}
{
if( lw->selected < length-1 )
lw->selected++;
+ else if ( options.list_wrap )
+ lw->selected = 0;
}
void
-list_window_previous(list_window_t *lw)
+list_window_previous(list_window_t *lw, int length)
{
if( lw->selected > 0 )
lw->selected--;
+ else if( options.list_wrap )
+ lw->selected = length-1;
+}
+
+void
+list_window_right(list_window_t *lw, int length)
+{
+ lw->xoffset++;
+}
+
+void
+list_window_left(list_window_t *lw)
+{
+ if( lw->xoffset > 0 )
+ lw->xoffset--;
}
void
list_window_first(list_window_t *lw)
{
+ lw->xoffset = 0;
lw->selected = 0;
}
void
list_window_last(list_window_t *lw, int length)
{
+ lw->xoffset = 0;
lw->selected = length-1;
}
if( wrap )
{
i=0; /* first item */
- beep();
+ screen_bell();
}
}
return 1;
if( wrap )
{
i=rows-1; /* last item */
- beep();
+ screen_bell();
}
}
return 1;
switch(cmd)
{
case CMD_LIST_PREVIOUS:
- list_window_previous(lw);
+ list_window_previous(lw, rows);
lw->repaint=1;
break;
case CMD_LIST_NEXT:
diff --git a/src/list_window.h b/src/list_window.h
index 9e91703824205e6854ce213074337a6d1f6c812f..8f82791d13954e35351cae4a6fc8590dbaefacd2 100644 (file)
--- a/src/list_window.h
+++ b/src/list_window.h
int start;
int selected;
+ int xoffset;
int clear;
int repaint;
/* select functions */
void list_window_set_selected(list_window_t *lw, int n);
-void list_window_previous(list_window_t *lw);
+void list_window_previous(list_window_t *lw, int length);
void list_window_next(list_window_t *lw, int length);
void list_window_first(list_window_t *lw);
void list_window_last(list_window_t *lw, int length);
void list_window_previous_page(list_window_t *lw);
void list_window_next_page(list_window_t *lw, int length);
void list_window_check_selected(list_window_t *lw, int length);
+/* not implemented yet */
+void list_window_right(list_window_t *lw, int length);
+void list_window_left(list_window_t *lw);
/* find a string in a list window */
int list_window_find(list_window_t *lw,
diff --git a/src/main.c b/src/main.c
index 382897ddb2f172974f684f4fdf0d3ad4060398f0..f2a0e3d29a729e2016a7a5b035dceaf51c558ce4 100644 (file)
--- a/src/main.c
+++ b/src/main.c
#include "mpdclient.h"
#include "support.h"
#include "options.h"
+#include "conf.h"
#include "command.h"
#include "screen.h"
-#include "conf.h"
+#include "screen_utils.h"
#define BUFSIZE 256
break;
case MPD_ERROR_ACK:
screen_status_printf("%s", error_msg(msg));
- beep();
+ screen_bell();
break;
default:
screen_status_printf("%s", msg);
- beep();
+ screen_bell();
doupdate();
connected = FALSE;
}
}
/* set xterm title */
- /* if( g_getenv("DISPLAY") )
- * printf("%c]0;%s%c", '\033', PACKAGE " version " VERSION, '\007');
- */
+#ifdef DEBUG
+ options->enable_xterm_title = 1;
+ set_xterm_title(PACKAGE " version " VERSION);
+#endif
/* install exit function */
atexit(exit_and_cleanup);
diff --git a/src/mpdclient.h b/src/mpdclient.h
index c0d897d800f01fbb3888c03c089596132bd22acd..bb8771f65a8bf8ab67b5a2ce7114026543250b60 100644 (file)
--- a/src/mpdclient.h
+++ b/src/mpdclient.h
gint mpdclient_cmd_save_playlist(mpdclient_t *c, gchar *filename);
gint mpdclient_cmd_save_playlist_utf8(mpdclient_t *c, gchar *filename);
gint mpdclient_cmd_load_playlist_utf8(mpdclient_t *c, gchar *filename_utf8);
+gint mpdclient_cmd_delete_playlist(mpdclient_t *c, gchar *filename);
gint mpdclient_cmd_delete_playlist_utf8(mpdclient_t *c, gchar *filename_utf8);
diff --git a/src/screen_file.c b/src/screen_file.c
index 9f1d0b209403ef7c3460386f8a854b14de02ff5f..8b79f279f5971d9ee0bd747daf903d43c646ae3a 100644 (file)
--- a/src/screen_file.c
+++ b/src/screen_file.c
if( entity->type!=MPD_INFO_ENTITY_TYPE_PLAYLISTFILE )
{
screen_status_printf(_("You can only delete playlists!"));
- beep();
+ screen_bell();
return -1;
}
diff --git a/src/screen_keydef.c b/src/screen_keydef.c
index 809561b80bea1709478bff0706bacdaf759c9504..b85c094c557412f35b6d859d679e9513395e54ea 100644 (file)
--- a/src/screen_keydef.c
+++ b/src/screen_keydef.c
{
screen_status_printf(_("Error: Unable to create direcory ~/.ncmpc - %s"),
strerror(errno));
- beep();
+ screen_bell();
return -1;
}
if( (f=fopen(filename,"w")) == NULL )
{
screen_status_printf(_("Error: %s - %s"), filename, strerror(errno));
- beep();
+ screen_bell();
g_free(filename);
return -1;
}
screen_status_printf(_("Error: key %s is already used for %s"),
key2str(key),
get_key_command_name(cmd));
- beep();
+ screen_bell();
return;
}
cmds[cmd_index].keys[key_index] = key;
diff --git a/src/screen_utils.c b/src/screen_utils.c
index d6e19fa3ec1047c674ed83bd2c8638d1d957fcd8..c5efc8e7dfdde993e361beab4f5ede6bc9c79234 100644 (file)
--- a/src/screen_utils.c
+++ b/src/screen_utils.c
#define FIND_PROMPT _("Find: ")
#define RFIND_PROMPT _("Find backward: ")
+void
+screen_bell(void)
+{
+ if( options.audible_bell )
+ beep();
+ if( options.visible_bell )
+ flash();
+}
+
int
screen_getch(WINDOW *w, char *prompt)
{
else
{
screen_status_printf(_("Unable to find \'%s\'"), screen->findbuf);
- beep();
+ screen_bell();
}
return 1;
default:
doupdate();
colors_use(w, COLOR_LIST);
}
+
+void
+set_xterm_title(char *format, ...)
+{
+ /* the current xterm title exists under the WM_NAME property */
+ /* and can be retreived with xprop -id $WINDOWID */
+
+ if( options.enable_xterm_title && g_getenv("WINDOWID") )
+ {
+ char buffer[512];
+ va_list ap;
+
+ va_start(ap,format);
+ vsnprintf(buffer,sizeof(buffer),format,ap);
+ va_end(ap);
+ printf("%c]0;%s%c", '\033', buffer, '\007');
+ }
+}
diff --git a/src/screen_utils.h b/src/screen_utils.h
index d60a33824e7eef00b964d8a51f34da254bb4b20d..56e44d533d882ea095b73df3924d785247d2ae65 100644 (file)
--- a/src/screen_utils.h
+++ b/src/screen_utils.h
#ifndef SCREEN_UTILS_H
#define SCREEN_UTILS_H
+/* sound an audible and/or visible bell */
+void screen_bell(void);
+
/* read a characher from the status window */
int screen_getch(WINDOW *w, char *prompt);
void screen_display_completion_list(screen_t *screen, GList *list);
+void set_xterm_title(char *format, ...);
+
#endif
diff --git a/src/wreadln.c b/src/wreadln.c
index ea0824d31f281f29ccb4612fbb77e4e44d47b5a5..dd69b417aa3092f1c68d84222da16f1f7b22eea3 100644 (file)
--- a/src/wreadln.c
+++ b/src/wreadln.c
wrln_gcmp_pre_cb_t wrln_pre_completion_callback = NULL;
wrln_gcmp_post_cb_t wrln_post_completion_callback = NULL;
+extern void screen_bell(void);
char *
wreadln(WINDOW *w,
g_free(prefix);
}
else
- beep();
+ screen_bell();
if( wrln_post_completion_callback )
wrln_post_completion_callback(gcmp, line, list);
}
break;
case KEY_CTRL_G:
- beep();
+ screen_bell();
g_free(line);
if( history )
{