command.h: include config.h
The source command.h checks for configure.ac options, so it needs to
include config.h.
The source command.h checks for configure.ac options, so it needs to
include config.h.
charset: don't allocate GError
Since the GError return value of g_convert_*() is ignored by ncmpc, we
don't need to retrieve it at all.
Since the GError return value of g_convert_*() is ignored by ncmpc, we
don't need to retrieve it at all.
options: don't store disabled options
Options which are disabled at compile time shouldn't reserve space for
their values in the options struct.
Options which are disabled at compile time shouldn't reserve space for
their values in the options struct.
options: static initialization if possible
Initialize the options struct statically.
Initialize the options struct statically.
options: removed deprecated options
"reconnect" is always enabled. "debug" code has been removed.
"reconnect" is always enabled. "debug" code has been removed.
configure.ac: added --disable-help-screen
configure.ac: added --disable-nls
Option --disable-nls disables all NLS features, even if the system
supports it.
Option --disable-nls disables all NLS features, even if the system
supports it.
configure.ac: added option --enable-mini
The option --enable-mini disables lots of features, and tries to
create a ncmpc binary which fits on very small machines.
The option --enable-mini disables lots of features, and tries to
create a ncmpc binary which fits on very small machines.
configure.ac: renamed $use_wide to $enable_wide
configure.ac: removed deprecated result line
configure.ac: added LIRC configure switch
Detect liblircclient with pkg-config.
Detect liblircclient with pkg-config.
lirc: pass writable string to lirc_init()
The "prog" argument of lirc_init() expects a non-const string.
Pass a local string variable.
The "prog" argument of lirc_init() expects a non-const string.
Pass a local string variable.
native LIRC support for ncmpc
The attachment includes the patch and a sample .lircrc config for
testing purposes (i. e. only a few commands are mapped to IR events).
The config is rather simple to write: For each button add a block like
this to ~/.lircrc:
begin
button = <button name from /etc/lircd.conf>
prog = ncmpc
config = <command name from src/command.c>
end
The patch is not finished, there are several problems that still need to
be solved:
1. the configure.ac modifications are just for testing purposes and
should be made optional with a parameter like --enable-lirc
for ./configure. Unfortunately I'm not an expert on autoconfig tools.
2. LIRC example code [1] suggests looping over lirc_code2char, probably
to have multiple actions that can be triggered from one button. Perhaps
lirc_event(...) should be moved to lirc.c and be heavily modified, no
longer being a mere copy of keyboard_event(...).
The attachment includes the patch and a sample .lircrc config for
testing purposes (i. e. only a few commands are mapped to IR events).
The config is rather simple to write: For each button add a block like
this to ~/.lircrc:
begin
button = <button name from /etc/lircd.conf>
prog = ncmpc
config = <command name from src/command.c>
end
The patch is not finished, there are several problems that still need to
be solved:
1. the configure.ac modifications are just for testing purposes and
should be made optional with a parameter like --enable-lirc
for ./configure. Unfortunately I'm not an expert on autoconfig tools.
2. LIRC example code [1] suggests looping over lirc_code2char, probably
to have multiple actions that can be triggered from one button. Perhaps
lirc_event(...) should be moved to lirc.c and be heavily modified, no
longer being a mere copy of keyboard_event(...).
Makefile.am: require automake 1.9
Makefile.am uses several features which are not available in the
ancient automake version 1.6. Let's just raise the bar to 1.9.
Makefile.am uses several features which are not available in the
ancient automake version 1.6. Let's just raise the bar to 1.9.
configure.ac: disable libtool
libtool isn't required for the ncmpc build process, it only causes
massive slowdown.
libtool isn't required for the ncmpc build process, it only causes
massive slowdown.
configure.ac: disabled the C++ and fortran checks
Why check for C++ and fortran compilers? This hack was borrowed from
Qball's gmpc git repository.
Why check for C++ and fortran compilers? This hack was borrowed from
Qball's gmpc git repository.
screen_browser: fix warning when lyrics screen is disabled
A local variable was only used by the lyrics screen code. Put #ifdef
around its declaration.
A local variable was only used by the lyrics screen code. Put #ifdef
around its declaration.
wreadln: support wide characters
wreadln() didn't distinguish narrow from wide characters, which
resulted in display corruption. This patch adds a lot of internal
conversions between byte positions, screen positions and character
position, which hopefully fixes all these bugs. Since these
conversions are quite expensive, the code should be revised and
optimized.
wreadln() didn't distinguish narrow from wide characters, which
resulted in display corruption. This patch adds a lot of internal
conversions between byte positions, screen positions and character
position, which hopefully fixes all these bugs. Since these
conversions are quite expensive, the code should be revised and
optimized.
wreadln: wait for complete multibyte sequence in wreadln_insert_byte()
For multibyte input, we should use wget_wch(), but this function isn't
supported properly on some platforms. Add a patch which completes a
multibyte character with multiple non-blocking reads. We'll see how
portable this hack is...
For multibyte input, we should use wget_wch(), but this function isn't
supported properly on some platforms. Add a patch which completes a
multibyte character with multiple non-blocking reads. We'll see how
portable this hack is...
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.
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.
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.
The configure option "--disable-wide" disables wide character support.
This simplifies lots of internal calculations and makes the ncmpc
binary leaner.
include ncursesw/ncurses.h if available
When compiling with libncursesw, include <ncursesw/ncurses.h> instead
of <ncurses.h> (if available).
When compiling with libncursesw, include <ncursesw/ncurses.h> instead
of <ncurses.h> (if available).
wreadln: optimize wreadln_delete_char() with memmove()
Let memmove() do the dirty work on overlapping buffers..
Let memmove() do the dirty work on overlapping buffers..
wreadln: moved code to wreadln_delete()
Remove some more clutter from wreadln() by merging the duplicate
character deletion code to wreadln_delete_char().
Remove some more clutter from wreadln() by merging the duplicate
character deletion code to wreadln_delete_char().
wreadln: return early from cursor movement functions
Unclutter these functions by removing one indent level.
Unclutter these functions by removing one indent level.
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.
Declare all screen position variables as "unsigned", and all buffer
positions as "size_t". We don't need signed values.
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.
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.
wreadln: use memmove() instead of an temporary buffer
memmove() handles overlapping buffers well, we can use it to get room
for the inserted character.
memmove() handles overlapping buffers well, we can use it to get room
for the inserted character.
wreadln: moved code to insert_byte()
Remove some clutter from wreadln(), isolate some code into a function.
Remove some clutter from wreadln(), isolate some code into a function.
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.
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.
wreadln: added struct wreadln
Don't pass a dozen of parameters to all internal functions; pass a
pointer to the wreadln struct instead.
Don't pass a dozen of parameters to all internal functions; pass a
pointer to the wreadln struct instead.
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.
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.
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.
Convert wrln_max_line_size and wrln_max_history_length to local
constants. They have no real use outside of wreadln.c.
wreadln: import screen_bell() from screen_utils.h
Don't use "extern" outside of the headers, include the proper header
instead.
Don't use "extern" outside of the headers, include the proper header
instead.
code style, indent with tabs XII
Follow the same code style als MPD itself.
Follow the same code style als MPD itself.
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.
There are no special cases left for my_wgetch() to handle. We can
remove it and use the original wgetch() instead.
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...
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...
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.
The wide character version of wreadln() is currently a non-functional
mess. Remove it for now, I will reimplement that later.
screen: declare time constants as GTime
Variables which store integer seconds should be declared as GTime.
This fixes a gcc warning.
Variables which store integer seconds should be declared as GTime.
This fixes a gcc warning.
Do not include libgen.h, it is unneeded after commit 44ecb.
use g_basename() instead of basename()
Another occurence of the non-portable basename() wasn't converted to
glib yet.
Another occurence of the non-portable basename() wasn't converted to
glib yet.
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.
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.
don't initialize sigaction struct twice
Don't reset sa_mask and sa_flags after every sigaction() call. Do it
once.
Don't reset sa_mask and sa_flags after every sigaction() call. Do it
once.
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.
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.
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.
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.
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.
screen_t is a singleton. We do not have to pass it around
everywhere. Export the one global variable.
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.
None of the paint() implementations acutally uses the mpdclient
pointer. Remove it from the method signature.
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().
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().
screen: removed "painted" flag
Repaint immediately instead of setting "painted=0".
Repaint immediately instead of setting "painted=0".
removed KEY_RESIZE
Since we are handling SIGWINCH, we do not need to handle KEY_RESIZE
from ncurses. Remove it.
Since we are handling SIGWINCH, we do not need to handle KEY_RESIZE
from ncurses. Remove it.
screen_search: array index is tag id
Save some bytes again: remove search_tag.id, make the array index
equal to the tag id.
Save some bytes again: remove search_tag.id, make the array index
equal to the tag id.
don't import mpdclient_finish_command() twice
mpdclient_finish_command() is already imported by mpdclient.h, don't
do it again in the sources.
mpdclient_finish_command() is already imported by mpdclient.h, don't
do it again in the sources.
screen_search: removed the FUTURE macro
The future is now!
The future is now!
options: don't initialize with memset(0)
Global variables are already initialized with zero when the program
starts, don't memset(0) again.
Global variables are already initialized with zero when the program
starts, don't memset(0) again.
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.
Just make everybody use the global "options" variable. This
eliminates namespace confusion and the NO_GLOBAL_OPTIONS hack.
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.
Default is colors disabled. Those who love colorful terminals have
the option to enable it with --enable-colors.
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().
Instead of calling printf() multiple times for every compile time
option, build the whole string at compile time and print it with
puts().
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.
The color ids are sequential, and we can save some bytes if we use it
for the array index.
colors: added enum color_t
Instead of declaring a bunch of CPP macros, use a C enum for
identifying colors.
Instead of declaring a bunch of CPP macros, use a C enum for
identifying colors.
code style, indent with tabs XI
Follow the same code style als MPD itself.
Follow the same code style als MPD itself.
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".
The artist screen shouldn't be marked "experimental" anymore.
Describe the current state of the screen in the title, instead of
always writing "Artist".
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.
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.
filelist: added filelist_find_directory()
The function filelist_find_directory() will be useful for the
following patch.
The function filelist_find_directory() will be useful for the
following patch.
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.
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.
charset: pass -1 instead of strlen()
The GTK charset functions accept "-1" if the parameter is null
terminated.
The GTK charset functions accept "-1" if the parameter is null
terminated.
support: removed unused function remove_trailing_slash()
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().
g_basename() is always available, no need to implement a fallback.
Also use g_path_get_dirname(), g_path_get_basename().
use g_ascii_isspace() instead of IS_WHITESPACE()
Don't duplicate code which is already provided by glib.
Don't duplicate code which is already provided by glib.
use g_ascii_strdown() instead of the custom lowerstr()
Don't duplicate code which is already provided by glib.
Don't duplicate code which is already provided by glib.
list_window: removed unused macro "LW_ROW"
screen_browser: added constant playlist_format
Moved the format string for playlist files to the constant
"playlist_format".
Moved the format string for playlist files to the constant
"playlist_format".
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.
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.
screen_lyrics: character set conversion
Convert the lyrics to the current character set before displaying
them.
Convert the lyrics to the current character set before displaying
them.
charset: convert strings with fallback
Use g_convert_with_fallback() for charset conversion, and don't print
a status bar message on error.
Use g_convert_with_fallback() for charset conversion, and don't print
a status bar message on error.
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.
Don't pass "noconvert" to charset_init(). Let charset_init()
determine that with g_get_charset() and return its name.
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".
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".
moved code to charset.c
Move everything which deals with UTF-8 strings and character set
conversion to charset.c, header charset.h.
Move everything which deals with UTF-8 strings and character set
conversion to charset.c, header charset.h.
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.
Moved constants which are only used in one source file. Remove
several unused macros.
removed LIST_FORMAT, STATUS_FORMAT
Use options.list_format and options.status_format directly instead of
these two macros.
Use options.list_format and options.status_format directly instead of
these two macros.
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.
Don't make everybody include ncmpc.h just to have generic features.
Move generic i18n macros to a separate header.
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.
Use the standard "bool" type instead of glib's "gboolean". This way,
options.h doesn't have to include the fat glib.h.
removed the deprecated easy_download library
This library isn't being used anymore, delete it.
This library isn't being used anymore, delete it.
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.
These macros are only used by options.c and conf.c. Move them to a
common internal header.
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.
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.
removed the debugging function D()
gdb is for debugging. We don't need D() calls littered all over.
gdb is for debugging. We don't need D() calls littered all over.
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.
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.
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.
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.
screen: export function screen_switch()
Provide an API for switching the currently displayed screen. Rename
switch_screen_mode() to screen_switch().
Provide an API for switching the currently displayed screen. Rename
switch_screen_mode() to screen_switch().
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.
Since the method types are used only once, we do not need typedefs for
that. Declare the method types within struct screen_functions.
screen_browser: added browser_cmd()
Merge a lot of code from the 3 browser screen into browser_cmd().
Merge a lot of code from the 3 browser screen into browser_cmd().
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.
By calling artist_lw_cmd() after the big switch, we can override
behaviour, and we can modify the command.
screen_artist: don't call wrefresh() twice
artist_repaint() calls wrefresh(), don't call it again after
that.
artist_repaint() calls wrefresh(), don't call it again after
that.
strfsong: constant pointers
Pass constant pointers to strfsong() and screen_lyrics_load().
Pass constant pointers to strfsong() and screen_lyrics_load().
screen: include config.h in screen.h
Since screen.h checks the macros from config.h, we have to include it.
Since screen.h checks the macros from config.h, we have to include it.
Makefile.am: don't use $(addprefix ...)
The function "addprefix" is a GNU extension, don't use it.
The function "addprefix" is a GNU extension, don't use it.
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.
The variable $(lyrics_plugin_dir) was already declared in
configure.ac, don't declare it again in Makefile.am.
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.
Everybody who uses the ENABLE_ macros has to include ncmpc.h. We're
better off defining those in config.h via configure.ac.
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.
Due to a missing sync_highlights() call, highlights were gone when the
user pressed the "update" hot key.
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.
"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.
screen_artist: replaced update_metalist()
Replaced update_metalist() with three specialized functions for mode
switching.
Replaced update_metalist() with three specialized functions for mode
switching.