From f6d8ba3c8de6c409c39fcaabe4e5c8fa86a7614a Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 19 May 2015 08:17:38 +0000 Subject: dtas-console: bind "o" to display time in absolute seconds It can be useful to display time as absolute seconds to ease arithmetic for tracking files. --- bin/dtas-console | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'bin') 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? -- cgit v1.2.3-24-ge0c7