everything related to duct tape audio suite (dtas)
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: <dtas-all@nongnu.org>
Cc: Eric Wong <e@80x24.org>
Subject: [PATCH] dtas-console: bind "o" to display time in absolute seconds
Date: Tue, 19 May 2015 08:18:28 +0000	[thread overview]
Message-ID: <1432023508-2539-1-git-send-email-e@80x24.org> (raw)

It can be useful to display time as absolute seconds to
ease arithmetic for tracking files.
---
 Documentation/dtas-console.txt |  1 +
 bin/dtas-console               | 16 +++++++++++-----
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/Documentation/dtas-console.txt b/Documentation/dtas-console.txt
index 55b0bde..2547036 100644
--- a/Documentation/dtas-console.txt
+++ b/Documentation/dtas-console.txt
@@ -33,6 +33,7 @@ Key bindings are inspired partially by mplayer(1)
 - 'f'/'F' - decrease/increase ReplayGain fallback_gain value
 - 'r'/'R' - cycle forward/backwards through ReplayGain modes
 - 'q'/Ctrl-C - exit dtas-console
+- 'o' - toggle display between HH:MM:SS and absolute seconds
 
 # ENVIRONMENT
 
diff --git a/bin/dtas-console b/bin/dtas-console
index 9fa4d09..a98244b 100755
--- a/bin/dtas-console
+++ b/bin/dtas-console
@@ -14,6 +14,7 @@ rescue LoadError
   abort "please install the 'curses' RubyGem to use #$0"
 end
 
+tsec = false
 se = DTAS::Sigevent.new
 trap(:WINCH) { se.signal }
 w = DTAS::UNIXClient.new
@@ -30,8 +31,12 @@ else
   rg_mode_i = 0
 end
 
-def update_tfmt(prec)
-  prec == 0 ? '%H:%M:%S' : "%H:%M:%S.%#{prec}N"
+def update_tfmt(prec, tsec)
+  if tsec
+    prec == 0 ? '%_8s' : "%_8s.%#{prec}N"
+  else
+    prec == 0 ? '%H:%M:%S' : "%H:%M:%S.%#{prec}N"
+  end
 end
 trap(:INT) { exit(0) }
 trap(:TERM) { exit(0) }
@@ -40,7 +45,7 @@ trap(:TERM) { exit(0) }
 prec_nr = 1
 prec_step = (0..9).to_a
 prec_max = prec_step.size - 1
-tfmt = update_tfmt(prec_step[prec_nr])
+tfmt = update_tfmt(prec_step[prec_nr], tsec)
 events = []
 interval = 1.0 / 10 ** prec_nr
 
@@ -209,6 +214,7 @@ begin
         when "<" then c.req_ok("tl prev")
         when "!" then may_fail(c.req("cue prev"), events)
         when "@" then may_fail(c.req("cue next"), events)
+        when "o" then tfmt = update_tfmt(prec_step[prec_nr], tsec = !tsec)
         when " "
           c.req("play_pause")
         when "r" # cycle through replaygain modes
@@ -219,13 +225,13 @@ begin
         when "p" # lower precision of time display
           if prec_nr >= 1
             prec_nr -= 1
-            tfmt = update_tfmt(prec_step[prec_nr])
+            tfmt = update_tfmt(prec_step[prec_nr], tsec)
             interval = 1.0 / 10 ** prec_nr
           end
         when "P" # increase precision of time display
           if prec_nr < prec_max
             prec_nr += 1
-            tfmt = update_tfmt(prec_step[prec_nr])
+            tfmt = update_tfmt(prec_step[prec_nr], tsec)
             interval = 1.0 / 10 ** prec_nr
           end
         when 27 # TODO readline/edit mode?
-- 
EW



                 reply	other threads:[~2015-05-19  8:18 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://80x24.org/dtas/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1432023508-2539-1-git-send-email-e@80x24.org \
    --to=e@80x24.org \
    --cc=dtas-all@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/dtas.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).