Code

ncmpc.git
15 years agowreadln: don't use cursor_move_right() in insert_byte()
Max Kellermann [Mon, 6 Oct 2008 14:55:35 +0000 (16:55 +0200)]
wreadln: don't use cursor_move_right() in insert_byte()

After a byte has been inserted, move the cursor right by just one
byte, not one character.  The byte may have been the first one in a
multibyte character.

15 years agoconfigure.ac: added option --disable-wide
Max Kellermann [Mon, 6 Oct 2008 14:54:54 +0000 (16:54 +0200)]
configure.ac: added option --disable-wide

The configure option "--disable-wide" disables wide character support.
This simplifies lots of internal calculations and makes the ncmpc
binary leaner.

15 years agoinclude ncursesw/ncurses.h if available
Max Kellermann [Mon, 6 Oct 2008 14:03:24 +0000 (16:03 +0200)]
include ncursesw/ncurses.h if available

When compiling with libncursesw, include <ncursesw/ncurses.h> instead
of <ncurses.h> (if available).

15 years agowreadln: optimize wreadln_delete_char() with memmove()
Max Kellermann [Mon, 6 Oct 2008 12:56:18 +0000 (14:56 +0200)]
wreadln: optimize wreadln_delete_char() with memmove()

Let memmove() do the dirty work on overlapping buffers..

15 years agowreadln: moved code to wreadln_delete()
Max Kellermann [Mon, 6 Oct 2008 12:56:15 +0000 (14:56 +0200)]
wreadln: moved code to wreadln_delete()

Remove some more clutter from wreadln() by merging the duplicate
character deletion code to wreadln_delete_char().

15 years agowreadln: return early from cursor movement functions
Max Kellermann [Mon, 6 Oct 2008 12:56:13 +0000 (14:56 +0200)]
wreadln: return early from cursor movement functions

Unclutter these functions by removing one indent level.

15 years agowreadln: use unsigned integers and size_t
Max Kellermann [Mon, 6 Oct 2008 12:56:08 +0000 (14:56 +0200)]
wreadln: use unsigned integers and size_t

Declare all screen position variables as "unsigned", and all buffer
positions as "size_t".  We don't need signed values.

15 years agowreadln: use memcpy() for both cases
Max Kellermann [Mon, 6 Oct 2008 12:55:31 +0000 (14:55 +0200)]
wreadln: use memcpy() for both cases

Use memcpy() even when the cursor is at the end.  It copies only the
trailing null terminator in this case.

The constant "length" is declared here in preparation for the "wide
character" patches.

15 years agowreadln: use memmove() instead of an temporary buffer
Max Kellermann [Mon, 6 Oct 2008 12:55:31 +0000 (14:55 +0200)]
wreadln: use memmove() instead of an temporary buffer

memmove() handles overlapping buffers well, we can use it to get room
for the inserted character.

15 years agowreadln: moved code to insert_byte()
Max Kellermann [Mon, 6 Oct 2008 12:55:31 +0000 (14:55 +0200)]
wreadln: moved code to insert_byte()

Remove some clutter from wreadln(), isolate some code into a function.

15 years agowreadln: static buffer
Max Kellermann [Mon, 6 Oct 2008 12:55:20 +0000 (14:55 +0200)]
wreadln: static buffer

Since the buffer size is already known at compile time, don't do a
second malloc() for it, declare it statically in struct wreadln.  This
way, it is going to be allocated on the stack.

15 years agowreadln: added struct wreadln
Max Kellermann [Mon, 6 Oct 2008 12:55:01 +0000 (14:55 +0200)]
wreadln: added struct wreadln

Don't pass a dozen of parameters to all internal functions; pass a
pointer to the wreadln struct instead.

15 years agowreadln: removed parameter "x1"
Max Kellermann [Mon, 6 Oct 2008 12:38:22 +0000 (14:38 +0200)]
wreadln: removed parameter "x1"

Several internal functions calculate the width of the input field by
subtracting "x0" from "x1", although the width is already being passed
to them.  Eliminate the parameter "x1" in all functions, and use
"width" instead.

15 years agowreadln: convert public globals to local constants
Max Kellermann [Mon, 6 Oct 2008 12:36:29 +0000 (14:36 +0200)]
wreadln: convert public globals to local constants

Convert wrln_max_line_size and wrln_max_history_length to local
constants.  They have no real use outside of wreadln.c.

15 years agowreadln: import screen_bell() from screen_utils.h
Max Kellermann [Mon, 6 Oct 2008 12:34:49 +0000 (14:34 +0200)]
wreadln: import screen_bell() from screen_utils.h

Don't use "extern" outside of the headers, include the proper header
instead.

15 years agocode style, indent with tabs XII
Max Kellermann [Mon, 6 Oct 2008 12:34:09 +0000 (14:34 +0200)]
code style, indent with tabs XII

Follow the same code style als MPD itself.

15 years agoremoved my_wgetch(), switch to wgetch()
Max Kellermann [Mon, 6 Oct 2008 12:32:29 +0000 (14:32 +0200)]
removed my_wgetch(), switch to wgetch()

There are no special cases left for my_wgetch() to handle.  We can
remove it and use the original wgetch() instead.

15 years agodisable ncurses raw mode
Max Kellermann [Mon, 6 Oct 2008 12:31:33 +0000 (14:31 +0200)]
disable ncurses raw mode

We're better off doing our own signal handling, instead of switching
ncurses to raw mode.  Anyway, it was commented out and didn't work...

15 years agowreadln: removed the disabled ncursesw code
Max Kellermann [Mon, 6 Oct 2008 12:30:14 +0000 (14:30 +0200)]
wreadln: removed the disabled ncursesw code

The wide character version of wreadln() is currently a non-functional
mess.  Remove it for now, I will reimplement that later.

15 years agoscreen: declare time constants as GTime
Max Kellermann [Sat, 4 Oct 2008 10:23:51 +0000 (12:23 +0200)]
screen: declare time constants as GTime

Variables which store integer seconds should be declared as GTime.
This fixes a gcc warning.

15 years agoDo not include libgen.h, it is unneeded after commit 44ecb.
Emanuele Giaquinta [Sat, 4 Oct 2008 10:23:47 +0000 (12:23 +0200)]
Do not include libgen.h, it is unneeded after commit 44ecb.

15 years agouse g_basename() instead of basename()
Max Kellermann [Sat, 4 Oct 2008 10:23:29 +0000 (12:23 +0200)]
use g_basename() instead of basename()

Another occurence of the non-portable basename() wasn't converted to
glib yet.

15 years agostore MPD_UPDATE_TIME as guint
Max Kellermann [Fri, 3 Oct 2008 13:35:58 +0000 (15:35 +0200)]
store MPD_UPDATE_TIME as guint

The glib function g_timeout_add() wants the interval as guint in
milliseconds.  Store the update interval in this form, instead of
having to multiply MPD_UPDATE_TIME with 1000.

15 years agodon't initialize sigaction struct twice
Max Kellermann [Fri, 3 Oct 2008 13:24:01 +0000 (15:24 +0200)]
don't initialize sigaction struct twice

Don't reset sa_mask and sa_flags after every sigaction() call.  Do it
once.

15 years agorestart system call after SIGWINCH
Max Kellermann [Fri, 3 Oct 2008 13:23:51 +0000 (15:23 +0200)]
restart system call after SIGWINCH

Set option SA_RESTART for the SIGWINCH handler.  The screen resizer
function is called by the glib main loop anyway, no need to interrupt
any random system call here.

15 years agotypo: ignore SIGPIPE instead of SIGWINCH
Max Kellermann [Fri, 3 Oct 2008 13:23:46 +0000 (15:23 +0200)]
typo: ignore SIGPIPE instead of SIGWINCH

Somehow the "ignore SIGPIPE" patch had a fatal typo: instead of
ignoring SIGPIPE, it ignored SIGWINCH.  Somehow ncurses managed to
hide the bug's symptoms, but a recent patch finally broke it.  Repair
the typo.

15 years agoscreen: export the global variable "screen"
Max Kellermann [Fri, 3 Oct 2008 12:31:00 +0000 (14:31 +0200)]
screen: export the global variable "screen"

screen_t is a singleton.  We do not have to pass it around
everywhere.  Export the one global variable.

15 years agoscreen: don't pass mpdclient pointer to method paint()
Max Kellermann [Fri, 3 Oct 2008 12:30:59 +0000 (14:30 +0200)]
screen: don't pass mpdclient pointer to method paint()

None of the paint() implementations acutally uses the mpdclient
pointer.  Remove it from the method signature.

15 years agoscreen_play: remember playlist
Max Kellermann [Fri, 3 Oct 2008 12:30:08 +0000 (14:30 +0200)]
screen_play: remember playlist

Remove the last paint() dependency on the mpdclient pointer: remember
a pointer to the playlist object, and don't take it from mpdclient
every time we paint.  Also add the variable "current_song_id" which is
calculated in update().

15 years agoscreen: removed "painted" flag
Max Kellermann [Fri, 3 Oct 2008 12:28:49 +0000 (14:28 +0200)]
screen: removed "painted" flag

Repaint immediately instead of setting "painted=0".

15 years agoremoved KEY_RESIZE
Max Kellermann [Fri, 3 Oct 2008 12:28:43 +0000 (14:28 +0200)]
removed KEY_RESIZE

Since we are handling SIGWINCH, we do not need to handle KEY_RESIZE
from ncurses.  Remove it.

15 years agoscreen_search: array index is tag id
Max Kellermann [Fri, 3 Oct 2008 12:28:42 +0000 (14:28 +0200)]
screen_search: array index is tag id

Save some bytes again: remove search_tag.id, make the array index
equal to the tag id.

15 years agodon't import mpdclient_finish_command() twice
Max Kellermann [Fri, 3 Oct 2008 12:26:29 +0000 (14:26 +0200)]
don't import mpdclient_finish_command() twice

mpdclient_finish_command() is already imported by mpdclient.h, don't
do it again in the sources.

15 years agoscreen_search: removed the FUTURE macro
Max Kellermann [Fri, 3 Oct 2008 12:26:27 +0000 (14:26 +0200)]
screen_search: removed the FUTURE macro

The future is now!

15 years agooptions: don't initialize with memset(0)
Max Kellermann [Fri, 3 Oct 2008 12:26:00 +0000 (14:26 +0200)]
options: don't initialize with memset(0)

Global variables are already initialized with zero when the program
starts, don't memset(0) again.

15 years agooptions: don't pass the "options" pointer around
Max Kellermann [Fri, 3 Oct 2008 12:25:45 +0000 (14:25 +0200)]
options: don't pass the "options" pointer around

Just make everybody use the global "options" variable.  This
eliminates namespace confusion and the NO_GLOBAL_OPTIONS hack.

15 years agocolors: make color support optional at compile time
Max Kellermann [Fri, 3 Oct 2008 12:25:00 +0000 (14:25 +0200)]
colors: make color support optional at compile time

Default is colors disabled.  Those who love colorful terminals have
the option to enable it with --enable-colors.

15 years agooptions: print one big string in --version screen
Max Kellermann [Fri, 3 Oct 2008 12:24:31 +0000 (14:24 +0200)]
options: print one big string in --version screen

Instead of calling printf() multiple times for every compile time
option, build the whole string at compile time and print it with
puts().

15 years agocolors: color id is the index of the "colors" array
Max Kellermann [Fri, 3 Oct 2008 12:24:28 +0000 (14:24 +0200)]
colors: color id is the index of the "colors" array

The color ids are sequential, and we can save some bytes if we use it
for the array index.

15 years agocolors: added enum color_t
Max Kellermann [Fri, 3 Oct 2008 10:57:31 +0000 (12:57 +0200)]
colors: added enum color_t

Instead of declaring a bunch of CPP macros, use a C enum for
identifying colors.

15 years agocode style, indent with tabs XI
Max Kellermann [Fri, 3 Oct 2008 10:57:30 +0000 (12:57 +0200)]
code style, indent with tabs XI

Follow the same code style als MPD itself.

15 years agoscreen_artist: better screen title
Max Kellermann [Fri, 3 Oct 2008 09:57:00 +0000 (11:57 +0200)]
screen_artist: better screen title

The artist screen shouldn't be marked "experimental" anymore.
Describe the current state of the screen in the title, instead of
always writing "Artist".

15 years agolist_window: remove list_window_state_t
Max Kellermann [Fri, 3 Oct 2008 09:56:00 +0000 (11:56 +0200)]
list_window: remove list_window_state_t

We do not need to save a stack of list window states.  When we return
to a parent directory, we just have to find the directory which we
come from in the parent list.  Note that this patch resets the cursor
when going to the root directory, but I think it's not that important,
and I will deal with that later.

15 years agofilelist: added filelist_find_directory()
Max Kellermann [Fri, 3 Oct 2008 09:53:55 +0000 (11:53 +0200)]
filelist: added filelist_find_directory()

The function filelist_find_directory() will be useful for the
following patch.

15 years agoscreen_artist: fix reload in "All tracks"
Max Kellermann [Fri, 3 Oct 2008 09:53:28 +0000 (11:53 +0200)]
screen_artist: fix reload in "All tracks"

The variable "album" was set to _("All tracks") when it was empty.
When reloading the songs, ncmpc was trying to find an album named "All
tracks", which didn't seem to work.  Leave "album" in its canonical
form and generate the title text on demand.

15 years agocharset: pass -1 instead of strlen()
Max Kellermann [Fri, 3 Oct 2008 09:52:13 +0000 (11:52 +0200)]
charset: pass -1 instead of strlen()

The GTK charset functions accept "-1" if the parameter is null
terminated.

15 years agosupport: removed unused function remove_trailing_slash()
Max Kellermann [Fri, 3 Oct 2008 09:51:53 +0000 (11:51 +0200)]
support: removed unused function remove_trailing_slash()

15 years agouse g_basename() instead of basename()
Max Kellermann [Fri, 3 Oct 2008 09:51:32 +0000 (11:51 +0200)]
use g_basename() instead of basename()

g_basename() is always available, no need to implement a fallback.
Also use g_path_get_dirname(), g_path_get_basename().

15 years agouse g_ascii_isspace() instead of IS_WHITESPACE()
Max Kellermann [Fri, 3 Oct 2008 09:50:42 +0000 (11:50 +0200)]
use g_ascii_isspace() instead of IS_WHITESPACE()

Don't duplicate code which is already provided by glib.

15 years agouse g_ascii_strdown() instead of the custom lowerstr()
Max Kellermann [Fri, 3 Oct 2008 09:50:30 +0000 (11:50 +0200)]
use g_ascii_strdown() instead of the custom lowerstr()

Don't duplicate code which is already provided by glib.

15 years agolist_window: removed unused macro "LW_ROW"
Max Kellermann [Thu, 2 Oct 2008 17:12:45 +0000 (19:12 +0200)]
list_window: removed unused macro "LW_ROW"

15 years agoscreen_browser: added constant playlist_format
Max Kellermann [Thu, 2 Oct 2008 17:11:15 +0000 (19:11 +0200)]
screen_browser: added constant playlist_format

Moved the format string for playlist files to the constant
"playlist_format".

15 years agofix compiler errors without locale.h
Max Kellermann [Thu, 2 Oct 2008 17:02:07 +0000 (19:02 +0200)]
fix compiler errors without locale.h

The code did not compile when HAVE_LOCALE_H was not set.  Also don't
compile all that code in charset.c, when there is no locale.h.

15 years agoscreen_lyrics: character set conversion
Max Kellermann [Thu, 2 Oct 2008 17:01:30 +0000 (19:01 +0200)]
screen_lyrics: character set conversion

Convert the lyrics to the current character set before displaying
them.

15 years agocharset: convert strings with fallback
Max Kellermann [Thu, 2 Oct 2008 17:01:11 +0000 (19:01 +0200)]
charset: convert strings with fallback

Use g_convert_with_fallback() for charset conversion, and don't print
a status bar message on error.

15 years agocharset: charset_init() returns character set
Max Kellermann [Thu, 2 Oct 2008 17:01:04 +0000 (19:01 +0200)]
charset: charset_init() returns character set

Don't pass "noconvert" to charset_init().  Let charset_init()
determine that with g_get_charset() and return its name.

15 years agocharset: renamed my_strlen() to utf8_width()
Max Kellermann [Thu, 2 Oct 2008 17:01:02 +0000 (19:01 +0200)]
charset: renamed my_strlen() to utf8_width()

my_strlen() is a bad name for the function, since the return value is
not a length, but a visible width on the screen.  Rename it to
utf8_width() and change its return type to "unsigned".

15 years agomoved code to charset.c
Max Kellermann [Thu, 2 Oct 2008 17:00:35 +0000 (19:00 +0200)]
moved code to charset.c

Move everything which deals with UTF-8 strings and character set
conversion to charset.c, header charset.h.

15 years agomoved macros from ncmpc.h to main.c and screen.c
Max Kellermann [Thu, 2 Oct 2008 17:00:28 +0000 (19:00 +0200)]
moved macros from ncmpc.h to main.c and screen.c

Moved constants which are only used in one source file.  Remove
several unused macros.

15 years agoremoved LIST_FORMAT, STATUS_FORMAT
Max Kellermann [Thu, 2 Oct 2008 15:48:01 +0000 (17:48 +0200)]
removed LIST_FORMAT, STATUS_FORMAT

Use options.list_format and options.status_format directly instead of
these two macros.

15 years agomoved i18n macros to i18n.h
Max Kellermann [Thu, 2 Oct 2008 15:48:00 +0000 (17:48 +0200)]
moved i18n macros to i18n.h

Don't make everybody include ncmpc.h just to have generic features.
Move generic i18n macros to a separate header.

15 years agooptions: use stdbool
Max Kellermann [Thu, 2 Oct 2008 15:47:01 +0000 (17:47 +0200)]
options: use stdbool

Use the standard "bool" type instead of glib's "gboolean".  This way,
options.h doesn't have to include the fat glib.h.

15 years agoremoved the deprecated easy_download library
Max Kellermann [Thu, 2 Oct 2008 14:52:26 +0000 (16:52 +0200)]
removed the deprecated easy_download library

This library isn't being used anymore, delete it.

15 years agomoved default value macros to defaults.h
Max Kellermann [Thu, 2 Oct 2008 14:52:25 +0000 (16:52 +0200)]
moved default value macros to defaults.h

These macros are only used by options.c and conf.c.  Move them to a
common internal header.

15 years agooptions: initialize options.list_format
Max Kellermann [Thu, 2 Oct 2008 14:15:56 +0000 (16:15 +0200)]
options: initialize options.list_format

Instead of checking whether options.list_format is set in the
LIST_FORMAT macro, initialize it once with options.list_format.  Same
for options.status_format / STATUS_FORMAT.

15 years agoremoved the debugging function D()
Max Kellermann [Thu, 2 Oct 2008 13:44:21 +0000 (15:44 +0200)]
removed the debugging function D()

gdb is for debugging.  We don't need D() calls littered all over.

15 years agoscreen_browser: unexport command implementations
Max Kellermann [Thu, 2 Oct 2008 13:30:47 +0000 (15:30 +0200)]
screen_browser: unexport command implementations

When we created created browser_cmd(), several functions of the
screen_browser API weren't used by other sources anymore.  We can now
unexport them.

15 years agoscreen_lyrics: add screen_lyrics_switch()
Max Kellermann [Thu, 2 Oct 2008 13:20:19 +0000 (15:20 +0200)]
screen_lyrics: add screen_lyrics_switch()

screen_lyrics_switch() opens the lyrics screen and displays the lyrics
of the specified song.  This way, the user may view the lyrics of any
song in the database browser.

15 years agoscreen: export function screen_switch()
Max Kellermann [Thu, 2 Oct 2008 13:20:18 +0000 (15:20 +0200)]
screen: export function screen_switch()

Provide an API for switching the currently displayed screen.  Rename
switch_screen_mode() to screen_switch().

15 years agoscreen: no typedefs for methods
Max Kellermann [Thu, 2 Oct 2008 13:20:18 +0000 (15:20 +0200)]
screen: no typedefs for methods

Since the method types are used only once, we do not need typedefs for
that.  Declare the method types within struct screen_functions.

15 years agoscreen_browser: added browser_cmd()
Max Kellermann [Thu, 2 Oct 2008 13:20:18 +0000 (15:20 +0200)]
screen_browser: added browser_cmd()

Merge a lot of code from the 3 browser screen into browser_cmd().

15 years agoscreen_artist: call artist_lw_cmd() at the end of artist_cmd()
Max Kellermann [Thu, 2 Oct 2008 13:20:18 +0000 (15:20 +0200)]
screen_artist: call artist_lw_cmd() at the end of artist_cmd()

By calling artist_lw_cmd() after the big switch, we can override
behaviour, and we can modify the command.

15 years agoscreen_artist: don't call wrefresh() twice
Max Kellermann [Thu, 2 Oct 2008 13:20:18 +0000 (15:20 +0200)]
screen_artist: don't call wrefresh() twice

artist_repaint() calls wrefresh(), don't call it again after
that.

15 years agostrfsong: constant pointers
Max Kellermann [Thu, 2 Oct 2008 13:20:18 +0000 (15:20 +0200)]
strfsong: constant pointers

Pass constant pointers to strfsong() and screen_lyrics_load().

15 years agoscreen: include config.h in screen.h
Max Kellermann [Thu, 2 Oct 2008 13:20:16 +0000 (15:20 +0200)]
screen: include config.h in screen.h

Since screen.h checks the macros from config.h, we have to include it.

15 years agoMakefile.am: don't use $(addprefix ...)
Max Kellermann [Thu, 2 Oct 2008 13:05:47 +0000 (15:05 +0200)]
Makefile.am: don't use $(addprefix ...)

The function "addprefix" is a GNU extension, don't use it.

15 years agoMakefile.am: don't declare $(lyrics_plugin_dir) twice
Max Kellermann [Thu, 2 Oct 2008 13:04:32 +0000 (15:04 +0200)]
Makefile.am: don't declare $(lyrics_plugin_dir) twice

The variable $(lyrics_plugin_dir) was already declared in
configure.ac, don't declare it again in Makefile.am.

15 years agoconfigure.ac: define ENABLE_x_SCREEN instead of DISABLE_x_SCREEN
Max Kellermann [Thu, 2 Oct 2008 12:57:42 +0000 (14:57 +0200)]
configure.ac: define ENABLE_x_SCREEN instead of DISABLE_x_SCREEN

Everybody who uses the ENABLE_ macros has to include ncmpc.h.  We're
better off defining those in config.h via configure.ac.

15 years agoscreen_file: set highlights after screen update
Max Kellermann [Wed, 1 Oct 2008 07:45:05 +0000 (09:45 +0200)]
screen_file: set highlights after screen update

Due to a missing sync_highlights() call, highlights were gone when the
user pressed the "update" hot key.

15 years agoscreen_artist: separate artist and album lists
Max Kellermann [Wed, 1 Oct 2008 07:38:45 +0000 (09:38 +0200)]
screen_artist: separate artist and album lists

"metalist" can have different meanings, depending on the mode.
Replace it with two separate variables "artist_list" and "album_list".
This way, we can optimize screen updates later.

15 years agoscreen_artist: replaced update_metalist()
Max Kellermann [Wed, 1 Oct 2008 07:38:27 +0000 (09:38 +0200)]
screen_artist: replaced update_metalist()

Replaced update_metalist() with three specialized functions for mode
switching.

15 years agoscreen_artist: added reload_lists()
Max Kellermann [Wed, 1 Oct 2008 07:38:25 +0000 (09:38 +0200)]
screen_artist: added reload_lists()

Some callers of update_metalist() want to reload the list contents.
Add an optimized function reload_lists() which does not modify the
global variables "mode", "artist", "album".

15 years agoscreen_artist: splitted update_metalist()
Max Kellermann [Wed, 1 Oct 2008 07:38:24 +0000 (09:38 +0200)]
screen_artist: splitted update_metalist()

Moved special cases for loading artist, album, song lists to separate
functions.

15 years agoscreen_artist: convert metalist to GPtrArray
Max Kellermann [Wed, 1 Oct 2008 07:37:51 +0000 (09:37 +0200)]
screen_artist: convert metalist to GPtrArray

A linked list is quite uncomfortable here because there is a lot of
indexed access to the list.  Use a GPtrArray of strings instead.

Note that mpdclient_get_artists_utf8() and mpdclient_get_albums_utf8()
return a linked list, and sorting is also performed on the linked
list.  This will be optimized later.

15 years agoscreen_artist: don't insert ".." and "all albums" into list
Max Kellermann [Wed, 1 Oct 2008 07:25:01 +0000 (09:25 +0200)]
screen_artist: don't insert ".." and "all albums" into list

Generate these special list entries on the fly.

15 years agoscreen_artist: moved code to artist_lw_cmd()
Max Kellermann [Wed, 1 Oct 2008 07:24:59 +0000 (09:24 +0200)]
screen_artist: moved code to artist_lw_cmd()

To unify the code, wrap list_window_cmd() in artist_lw_cmd(), which
properly checks the current mode.

15 years agoscreen_play: no song means id=-1
Max Kellermann [Sun, 28 Sep 2008 08:57:11 +0000 (10:57 +0200)]
screen_play: no song means id=-1

"prev_song_id" and "current_song_id" had value 0 if MPD was not
playing at all.  This way, ncmpc cannot see the difference between
"song 0 playing" and "not playing".  Change "not playing" to -1.

15 years agoscreen_play: repaint highlight when mpd starts playing
Max Kellermann [Sun, 28 Sep 2008 08:56:27 +0000 (10:56 +0200)]
screen_play: repaint highlight when mpd starts playing

When deciding whether to repaint the current highlight, test if MPD is
actually playing.  If MPD starts playing, repaint.

15 years agoscreen_play: repaint if current song has changed
Max Kellermann [Fri, 26 Sep 2008 06:48:31 +0000 (08:48 +0200)]
screen_play: repaint if current song has changed

The play_update() function was reduced too much: it didn't repaint the
screen when the current song changed.  Add check for that.

Don't repaint the screen in center_playing_item(), make the caller do
it.

15 years agoignore SIGPIPE
Max Kellermann [Fri, 26 Sep 2008 06:27:54 +0000 (08:27 +0200)]
ignore SIGPIPE

Ignore SIGPIPE, and handle errno==EPIPE instead.

15 years agodon't call lyrics_init if plugin is disabled
Max Kellermann [Thu, 25 Sep 2008 19:51:20 +0000 (21:51 +0200)]
don't call lyrics_init if plugin is disabled

If the lyrics screen is disabled at compile time, don't initialize the
lyrics library in main().

15 years agoscreen_browser: added hotkey for adding song
Max Kellermann [Thu, 25 Sep 2008 19:35:06 +0000 (21:35 +0200)]
screen_browser: added hotkey for adding song

CMD_ADD ('a') appends a song to the playlist, no matter if it is
already there, i.e. unlike CMD_SELECT, it does not toggle the song.

15 years agofix miscellaneous sparse warnings
Max Kellermann [Thu, 25 Sep 2008 19:24:58 +0000 (21:24 +0200)]
fix miscellaneous sparse warnings

Static variables, pointers vs integers, void function returning, ...

15 years agoMakefile: added "sparse-check" target
Max Kellermann [Thu, 25 Sep 2008 19:24:57 +0000 (21:24 +0200)]
Makefile: added "sparse-check" target

15 years agoscreen: removed screen.mode
Max Kellermann [Thu, 25 Sep 2008 19:21:29 +0000 (21:21 +0200)]
screen: removed screen.mode

Everything is now managed with a pointer to the screen_functions
struct.

15 years agoscreen: removed screen ids
Max Kellermann [Thu, 25 Sep 2008 19:21:27 +0000 (21:21 +0200)]
screen: removed screen ids

Finally remove all screen ids, they are not used anymore.

15 years agoscreen: pass screen_functions pointer to switch_screen_mode()
Max Kellermann [Thu, 25 Sep 2008 19:21:00 +0000 (21:21 +0200)]
screen: pass screen_functions pointer to switch_screen_mode()

Trying to get rid of the screen ids.  A pointer to screen_functions is
better for identifying a screen.

15 years agoscreen: replaced get_cur_mode_id() with screen_is_visible()
Max Kellermann [Thu, 25 Sep 2008 19:20:10 +0000 (21:20 +0200)]
screen: replaced get_cur_mode_id() with screen_is_visible()

Screen code shouldn't know anything about the screen ids (which will
be eliminated completely later).  Instead of comparing ids, compare
the screen_functions pointer.

15 years agoscreen: moved code to screen_list.c
Max Kellermann [Thu, 25 Sep 2008 19:20:06 +0000 (21:20 +0200)]
screen: moved code to screen_list.c

Move the hard-coded screen list and everything which works with this
array to screen_list.c.

15 years agoscreen: don't compile disabled sources
Max Kellermann [Thu, 25 Sep 2008 18:00:03 +0000 (20:00 +0200)]
screen: don't compile disabled sources

Instead of evaluating macros from config.h in the disabled source,
don't start the compiler on it at all.