Re: [Musicpd-dev-team] [PATCH] ncmpc: Adjustable seek time

2009-08-14 Thread Fredrik Lanker
On Fri, Aug 14, 2009 at 07:49:29AM +0200, Max Kellermann wrote:
 On 2009/08/14 02:24, Fredrik Lanker fredrik.lan...@gmail.com wrote:
  This patch for ncmpc makes it possible to adjust the seek time, in steps
  of 5 seconds, in runtime with 'F' and 'B'. The current seek time is
  displayed top right, next to the volume.
 
 Do you think this information is important enough to justify reserving
 permanent screen space?  I'd suggest using screen_status_printf() for
 displaying it shortly on the status line.
 ...
 Max

Well, yes and no. I agree it's not important enough to justify
cluttering the ui with it. On the other hand, you probably want to see
beforehand what the time is set to so that you know how far it will jump
when you seek. But I guess you could rely on your memory for that... ;)

Anyway, here is a modifed patch that uses screen_status_printf(), have
no leading whitespace and makes the string translatable. I leave it to
you to decide which version you want to use.

---

diff --git a/src/command.c b/src/command.c
index 3fe825c..e311254 100644
--- a/src/command.c
+++ b/src/command.c
@@ -130,6 +130,10 @@ static command_definition_t cmds[] = {
  N_(Seek forward) },
{ { 'b', 0, 0 }, 0, CMD_SEEK_BACKWARD, seek-backward,
  N_(Seek backward) },
+   { { 'F', 0, 0 }, 0, CMD_SEEK_TIME_INC, seek-time-increase,
+ N_(Increase seek time) },
+   { { 'B', 0, 0 }, 0, CMD_SEEK_TIME_DEC, seek-time-decrease,
+ N_(Decrease seek time) },
{ { '+', RGHT, 0 }, 0, CMD_VOLUME_UP, volume-up,
  N_(Increase volume) },
{ { '-', LEFT, 0 }, 0, CMD_VOLUME_DOWN, volume-down,
diff --git a/src/command.h b/src/command.h
index b3222c5..94ba37e 100644
--- a/src/command.h
+++ b/src/command.h
@@ -43,6 +43,8 @@ typedef enum {
CMD_TRACK_PREVIOUS,
CMD_SEEK_FORWARD,
CMD_SEEK_BACKWARD,
+   CMD_SEEK_TIME_INC,
+   CMD_SEEK_TIME_DEC,
CMD_SHUFFLE,
CMD_RANDOM,
CMD_CLEAR,
diff --git a/src/screen.c b/src/screen.c
index e540fec..1e1ec4b 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -796,7 +796,14 @@ screen_client_cmd(mpdclient_t *c, command_t cmd)
/* seek_target_time=0; */
}
break;
-   /* fall through... */
+   case CMD_SEEK_TIME_INC:
+   options.seek_time += (options.seek_time == 1) ? 4 : 5;
+   screen_status_printf(_(Seek time: %d s), options.seek_time);
+   break;
+   case CMD_SEEK_TIME_DEC:
+   options.seek_time = (options.seek_time  6) ? 1 : 
options.seek_time - 5;
+   screen_status_printf(_(Seek time: %d s), options.seek_time);
+   break;
case CMD_TRACK_NEXT:
if (!IS_STOPPED(c-status-state))
mpdclient_cmd_next(c);
diff --git a/src/screen_help.c b/src/screen_help.c
index 81b479f..567e396 100644
--- a/src/screen_help.c
+++ b/src/screen_help.c
@@ -86,6 +86,8 @@ static help_text_row_t help_text[] = {
{ 0, CMD_TRACK_PREVIOUS, NULL },
{ 0, CMD_SEEK_FORWARD, NULL },
{ 0, CMD_SEEK_BACKWARD, NULL },
+   { 0, CMD_SEEK_TIME_INC, NULL },
+   { 0, CMD_SEEK_TIME_DEC, NULL },
{ 0, CMD_VOLUME_DOWN, NULL },
{ 0, CMD_VOLUME_UP, NULL },
{ 0, CMD_NONE, NULL },

---

Fredrik

--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Musicpd-dev-team mailing list
Musicpd-dev-team@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/musicpd-dev-team


Re: [Musicpd-dev-team] [PATCH] ncmpc: Adjustable seek time

2009-08-14 Thread Fredrik Lanker
On Fri, Aug 14, 2009 at 02:43:44PM +0200, Max Kellermann wrote:
 On 2009/08/14 14:33, Fredrik Lanker fredrik.lan...@gmail.com wrote:
  Anyway, here is a modifed patch that uses screen_status_printf(), have
  no leading whitespace and makes the string translatable. I leave it to
  you to decide which version you want to use.
 
 I'll take this one.  Did you notice that your default hot key 'B' is
 duplicate? (scroll-up-half)
 
 Have you got a suggestion which key to use instead?
 
 Max

Ah, no, I've disabled the keys for scroll-up/down-half, so I missed
that, sorry. May I suggest changing the hot keys for scroll-*-half
instead? For two reasons:

1) having F/B for adjusting the seek time seems pretty obvious to me
considering that seeking have keys f/b.

2) in my opinion, the default hot key for scroll-down-half, N, should
instead be used for rfind-next, like it's used in Vim (and probably a
bounce of other apps).

And N/B don't seem to have any connection to scrolling, as far as I can
see, so changing them should be fine. O/I seems to be available in that
case.

Fredrik

--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Musicpd-dev-team mailing list
Musicpd-dev-team@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/musicpd-dev-team


[Musicpd-dev-team] [PATCH] ncmpc: Adjustable seek time

2009-08-13 Thread Fredrik Lanker
Hi!

This patch for ncmpc makes it possible to adjust the seek time, in steps
of 5 seconds, in runtime with 'F' and 'B'. The current seek time is
displayed top right, next to the volume.

---
 src/command.c |4 
 src/command.h |2 ++
 src/screen.c  |   11 ++-
 src/screen_help.c |2 ++
 4 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/src/command.c b/src/command.c
index 3fe825c..e311254 100644
--- a/src/command.c
+++ b/src/command.c
@@ -130,6 +130,10 @@ static command_definition_t cmds[] = {
  N_(Seek forward) },
{ { 'b', 0, 0 }, 0, CMD_SEEK_BACKWARD, seek-backward,
  N_(Seek backward) },
+   { { 'F', 0, 0 }, 0, CMD_SEEK_TIME_INC, seek-time-increase,
+ N_(Increase seek time) },
+   { { 'B', 0, 0 }, 0, CMD_SEEK_TIME_DEC, seek-time-decrease,
+ N_(Decrease seek time) },
{ { '+', RGHT, 0 }, 0, CMD_VOLUME_UP, volume-up,
  N_(Increase volume) },
{ { '-', LEFT, 0 }, 0, CMD_VOLUME_DOWN, volume-down,
diff --git a/src/command.h b/src/command.h
index b3222c5..94ba37e 100644
--- a/src/command.h
+++ b/src/command.h
@@ -43,6 +43,8 @@ typedef enum {
CMD_TRACK_PREVIOUS,
CMD_SEEK_FORWARD,
CMD_SEEK_BACKWARD,
+   CMD_SEEK_TIME_INC,
+   CMD_SEEK_TIME_DEC,
CMD_SHUFFLE,
CMD_RANDOM,
CMD_CLEAR,
diff --git a/src/screen.c b/src/screen.c
index e540fec..358a705 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -174,6 +174,7 @@ paint_top_window2(const char *header, mpdclient_t *c)
char flags[5];
WINDOW *w = screen.top_window.w;
char buf[32];
+   char seek[32];
 
if (header[0]) {
colors_use(w, COLOR_TITLE_BOLD);
@@ -206,8 +207,11 @@ paint_top_window2(const char *header, mpdclient_t *c)
else
g_snprintf(buf, 32, _(Volume %d%%), volume);
 
+   g_snprintf(seek, 32, _( Seek %ds ), options.seek_time);
+
colors_use(w, COLOR_TITLE);
mvwaddstr(w, 0, screen.top_window.cols - utf8_width(buf), buf);
+   mvwaddstr(w, 0, screen.top_window.cols - utf8_width(buf) - 
utf8_width(seek), seek);
 
flags[0] = 0;
if (c-status != NULL) {
@@ -796,7 +800,12 @@ screen_client_cmd(mpdclient_t *c, command_t cmd)
/* seek_target_time=0; */
}
break;
-   /* fall through... */
+case CMD_SEEK_TIME_INC:
+options.seek_time += (options.seek_time == 1) ? 4 : 5;
+   break;
+case CMD_SEEK_TIME_DEC:
+   options.seek_time = (options.seek_time  6) ? 1 : 
options.seek_time - 5;
+   break;
case CMD_TRACK_NEXT:
if (!IS_STOPPED(c-status-state))
mpdclient_cmd_next(c);
diff --git a/src/screen_help.c b/src/screen_help.c
index 81b479f..567e396 100644
--- a/src/screen_help.c
+++ b/src/screen_help.c
@@ -86,6 +86,8 @@ static help_text_row_t help_text[] = {
{ 0, CMD_TRACK_PREVIOUS, NULL },
{ 0, CMD_SEEK_FORWARD, NULL },
{ 0, CMD_SEEK_BACKWARD, NULL },
+   { 0, CMD_SEEK_TIME_INC, NULL },
+   { 0, CMD_SEEK_TIME_DEC, NULL },
{ 0, CMD_VOLUME_DOWN, NULL },
{ 0, CMD_VOLUME_UP, NULL },
{ 0, CMD_NONE, NULL },
-- 
1.6.0.4


Fredrik Lanker

--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Musicpd-dev-team mailing list
Musicpd-dev-team@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/musicpd-dev-team