summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 62e8aa2)
raw | patch | inline | side by side (parent: 62e8aa2)
author | Max Kellermann <max@duempel.org> | |
Mon, 6 Oct 2008 12:34:09 +0000 (14:34 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Mon, 6 Oct 2008 12:34:09 +0000 (14:34 +0200) |
Follow the same code style als MPD itself.
src/mpdclient.h | patch | blob | history | |
src/wreadln.c | patch | blob | history |
diff --git a/src/mpdclient.h b/src/mpdclient.h
index 2735f04ffa067d5cf9c12ff888704143281ab90a..a78aafa345d9278214bdfea68d9dbdc09cd535f8 100644 (file)
--- a/src/mpdclient.h
+++ b/src/mpdclient.h
GList *mpdclient_get_albums_utf8(mpdclient_t *c, gchar *artist_utf8);
-/*** error callbacks *****************************************************/
+/*** error callbacks *****************************************************/
#define IS_ACK_ERROR(n) (n & MPD_ERROR_ACK)
#define GET_ACK_ERROR_CODE(n) ((n & 0xFF00) >> 8)
/*** filelist functions ***************************************************/
mpdclient_filelist_t *mpdclient_filelist_get(mpdclient_t *c, const gchar *path);
-mpdclient_filelist_t *mpdclient_filelist_search(mpdclient_t *c,
+mpdclient_filelist_t *mpdclient_filelist_search(mpdclient_t *c,
int exact_match,
int table,
gchar *path);
-mpdclient_filelist_t *mpdclient_filelist_search_utf8(mpdclient_t *c,
+mpdclient_filelist_t *mpdclient_filelist_search_utf8(mpdclient_t *c,
int exact_match,
int table,
gchar *path);
-mpdclient_filelist_t *mpdclient_filelist_update(mpdclient_t *c,
+mpdclient_filelist_t *mpdclient_filelist_update(mpdclient_t *c,
mpdclient_filelist_t *flist);
/* add all songs in filelist to the playlist */
diff --git a/src/wreadln.c b/src/wreadln.c
index 7f00ef3ddd63ea5aa45624aefc1b3d364cfe4081..5962af703e631ca7eae6bd59b7fbb407ee15cf1b 100644 (file)
--- a/src/wreadln.c
+++ b/src/wreadln.c
static inline void cursor_move_left(gint *cursor,
gint *start)
{
- if( *cursor > 0 )
- {
- if( *cursor==*start && *start > 0 )
- (*start)--;
- (*cursor)--;
- }
+ if (*cursor > 0) {
+ if (*cursor == *start && *start > 0)
+ (*start)--;
+ (*cursor)--;
+ }
}
/* move the cursor to the end of the line */
gint x1,
gchar *line)
{
- *cursor = strlen(line);
- if( *cursor+x0 >= x1 )
- *start = *cursor-width+1;
+ *cursor = strlen(line);
+ if (*cursor + x0 >= x1)
+ *start = *cursor - width + 1;
}
/* draw line buffer and update cursor position */
gchar *line,
WINDOW *w)
{
- wmove(w, y, x0);
- /* clear input area */
- whline(w, ' ', width);
- /* print visible part of the line buffer */
- if(masked == TRUE) whline(w, '*', utf8_width(line) - start);
- else waddnstr(w, line+start, width);
- /* move the cursor to the correct position */
- wmove(w, y, x0 + cursor-start);
- /* tell ncurses to redraw the screen */
- doupdate();
+ wmove(w, y, x0);
+ /* clear input area */
+ whline(w, ' ', width);
+ /* print visible part of the line buffer */
+ if(masked == TRUE)
+ whline(w, '*', utf8_width(line) - start);
+ else
+ waddnstr(w, line+start, width);
+ /* move the cursor to the correct position */
+ wmove(w, y, x0 + cursor-start);
+ /* tell ncurses to redraw the screen */
+ doupdate();
}
-
/* libcurses version */
static gchar *
/* make shure the cursor is visible */
curs_set(1);
/* print prompt string */
- if( prompt )
+ if (prompt)
waddstr(w, prompt);
/* retrive y and x0 position */
getyx(w, y, x0);
/* check the x1 value */
- if( x1<=x0 || x1>COLS )
+ if (x1 <= x0 || x1 > COLS)
x1 = COLS;
- width = x1-x0;
+ width = x1 - x0;
/* clear input area */
mvwhline(w, y, x0, ' ', width);
- if( history ) {
+ if (history) {
/* append the a new line to our history list */
*history = g_list_append(*history, g_malloc0(wrln_max_line_size));
/* hlist points to the current item in the history list */
- hlist = g_list_last(*history);
+ hlist = g_list_last(*history);
hcurrent = hlist;
}
- if( initial_value == (char *) -1 ) {
+ if (initial_value == (char *)-1) {
/* get previous history entry */
- if( history && hlist->prev )
- {
- if( hlist==hcurrent )
- {
- /* save the current line */
- g_strlcpy(hlist->data, line, wrln_max_line_size);
- }
- /* get previous line */
- hlist = hlist->prev;
- g_strlcpy(line, hlist->data, wrln_max_line_size);
- }
+ if (history && hlist->prev) {
+ if (hlist == hcurrent)
+ /* save the current line */
+ g_strlcpy(hlist->data, line, wrln_max_line_size);
+
+ /* get previous line */
+ hlist = hlist->prev;
+ g_strlcpy(line, hlist->data, wrln_max_line_size);
+ }
cursor_move_to_eol(&cursor, &start, width, x0, x1, line);
drawline(cursor, start, width, x0, y, masked, line, w);
- } else if( initial_value ) {
+ } else if (initial_value) {
/* copy the initial value to the line buffer */
g_strlcpy(line, initial_value, wrln_max_line_size);
cursor_move_to_eol(&cursor, &start, width, x0, x1, line);
drawline(cursor, start, width, x0, y, masked, line, w);
}
- while( key!=13 && key!='\n' ) {
+ while (key != 13 && key != '\n') {
key = wgetch(w);
/* check if key is a function key */
- for(i=0; i<63; i++)
- if( key==KEY_F(i) ) {
- key=KEY_F(1);
- i=64;
+ for (i = 0; i < 63; i++)
+ if (key == KEY_F(i)) {
+ key = KEY_F(1);
+ i = 64;
}
switch (key) {
break;
case TAB:
- if( gcmp ) {
+ if (gcmp) {
char *prefix = NULL;
GList *list;
- if(wrln_pre_completion_callback)
+ if (wrln_pre_completion_callback)
wrln_pre_completion_callback(gcmp, line,
wrln_completion_callback_data);
list = g_completion_complete(gcmp, line, &prefix);
- if( prefix ) {
+ if (prefix) {
g_strlcpy(line, prefix, wrln_max_line_size);
cursor_move_to_eol(&cursor, &start, width, x0, x1, line);
g_free(prefix);
- }
- else
+ } else
screen_bell();
- if( wrln_post_completion_callback )
+
+ if (wrln_post_completion_callback)
wrln_post_completion_callback(gcmp, line, list,
wrln_completion_callback_data);
}
case KEY_CTRL_G:
screen_bell();
g_free(line);
- if( history ) {
+ if (history) {
g_free(hcurrent->data);
hcurrent->data = NULL;
*history = g_list_delete_link(*history, hcurrent);
case KEY_UP:
case KEY_CTRL_P:
/* get previous history entry */
- if( history && hlist->prev ) {
- if( hlist==hcurrent )
- {
- /* save the current line */
- g_strlcpy(hlist->data, line, wrln_max_line_size);
- }
+ if (history && hlist->prev) {
+ if (hlist == hcurrent)
+ /* save the current line */
+ g_strlcpy(hlist->data, line, wrln_max_line_size);
+
/* get previous line */
hlist = hlist->prev;
g_strlcpy(line, hlist->data, wrln_max_line_size);
case KEY_DOWN:
case KEY_CTRL_N:
/* get next history entry */
- if( history && hlist->next ) {
+ if (history && hlist->next) {
/* get next line */
hlist = hlist->next;
g_strlcpy(line, hlist->data, wrln_max_line_size);
}
/* update history */
- if( history ) {
- if( strlen(line) ) {
+ if (history) {
+ if (strlen(line)) {
/* update the current history entry */
size_t size = strlen(line)+1;
hcurrent->data = g_realloc(hcurrent->data, size);
*history = g_list_delete_link(*history, hcurrent);
}
- while( g_list_length(*history) > wrln_max_history_length ) {
+ while (g_list_length(*history) > wrln_max_history_length) {
GList *first = g_list_first(*history);
/* remove the oldest history entry */