From c5ff24358c7e51c7d25e18ec52ecd316b6af04ac Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 6 Oct 2012 14:52:41 -0400 Subject: [PATCH] Feature #934 - Feature #934, supports 'reserved.lines' to indicate a multi-line prompt for use in conjunction with 'limit:page' (thanks to Robert Gill). - Removed 'locale' from the taskrc.5 man page. - Added verbosity token 'sync'. - Fixed bug in size calculation for 'limit:page', but there is still one more. - Corrected unit test limit.t given the above fix. --- AUTHORS | 1 + ChangeLog.230 | 9 +++++++-- doc/man/taskrc.5.in | 9 +++++---- src/Config.cpp | 3 ++- src/Context.cpp | 6 +++++- src/commands/CmdCustom.cpp | 9 ++++++--- src/commands/CmdShow.cpp | 1 + src/commands/CmdSync.cpp | 3 +++ src/feedback.cpp | 19 +++++++++++++++++++ src/main.h | 1 + test/limit.t | 13 ++++++++++++- 11 files changed, 62 insertions(+), 12 deletions(-) diff --git a/AUTHORS b/AUTHORS index 6f0225037..b097a2b4d 100644 --- a/AUTHORS +++ b/AUTHORS @@ -156,4 +156,5 @@ suggestions: Rene Vergara Stéphane Pezennec Jim B + Robert Gill diff --git a/ChangeLog.230 b/ChangeLog.230 index f87b07c50..f73a8e96b 100644 --- a/ChangeLog.230 +++ b/ChangeLog.230 @@ -3,10 +3,15 @@ 2.3.0 () - Features + + Added Feature #934, support for 'reserved.lines' to accomodate multi-line + shell prompts when used in conjunction with 'limit:page' (thanks to Robert + Gill). + Stores un-synched transactions in /backlog.data. - + Adds a new "synchronize" command to sync data with a task server. + + Adds a new 'synchronize' command to sync data with a task server. + + Adds a new 'sync' verbosity token, which will reminds when a backlog builds + up and needs a sync. Bugs - + + + Fixed bug so that 'limit:page' now considers footnote messages. ------ old releases ------------------------------ diff --git a/doc/man/taskrc.5.in b/doc/man/taskrc.5.in index 3038a980e..a81c2027f 100644 --- a/doc/man/taskrc.5.in +++ b/doc/man/taskrc.5.in @@ -230,9 +230,9 @@ that you would see a smaller, more compact representation of the task, with no help text. Deprecated - use verbosity token 'edit'. .TP -.B locale=en-US.UTF8 -Locale to be used by Taskwarrior for synchronization with the task server. The -default value is currently blank. +.B reserved.lines=1 +This is the number of lines reserved at the bottom of the screen for the shell +prompt. This is only referenced when 'limit:page' is used. .SS MISCELLANEOUS @@ -258,6 +258,7 @@ control specific occasions when output is generated. This list may contain: edit Used the verbose template for the 'edit' command special Feedback when applying special tags project Feedback about project status changes + sync Feedback about the need for sync Note that the "on" setting is equivalent to all the tokens being specified, and the "nothing" setting is equivalent to none of the tokens being specified. @@ -265,7 +266,7 @@ and the "nothing" setting is equivalent to none of the tokens being specified. Here are the shortcut equivalents: verbose=on - verbose=blank,header,footnote,label,new-id,affected,edit,special,project + verbose=blank,header,footnote,label,new-id,affected,edit,special,project,sync verbose=off verbose=blank,label,new-id,edit diff --git a/src/Config.cpp b/src/Config.cpp index 2644477fd..a21def780 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -76,13 +76,14 @@ std::string Config::_defaults = "avoidlastcolumn=no # Fixes Cygwin width problem\n" "hyphenate=on # Hyphenates lines wrapped on non-word-breaks\n" "#editor=vi # Preferred text editor\n" + "reserved.lines=1 # Assume a 1-line prompt\n" "\n" "# Miscellaneous\n" "verbose=yes # Provide maximal feedback\n" "#verbose=no # Provide regular feedback\n" "#verbose=nothing # Provide no feedback\n" "# # Comma-separated list. May contain any subset of:\n" - "#verbose=blank,header,footnote,label,new-id,affected,edit,special,project\n" + "#verbose=blank,header,footnote,label,new-id,affected,edit,special,project,sync\n" "confirmation=yes # Confirmation on delete, big changes\n" "indent.annotation=2 # Indent spaces for annotations\n" "indent.report=0 # Indent spaces for whole report\n" diff --git a/src/Context.cpp b/src/Context.cpp index 19d321d79..c3da451da 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -451,6 +451,9 @@ bool Context::color () // rc.verbose=nothing Show the absolute minimum. // rc.verbose=one,two Show verbosity for 'one' and 'two' only. // +// TODO This mechanism is clunky, and should slowly evolve into something more +// logical and consistent. This should probably mean that 'nothing' should +// take the place of '0'. bool Context::verbose (const std::string& token) { if (! verbosity.size ()) @@ -470,7 +473,8 @@ bool Context::verbose (const std::string& token) verbosity[0] != "affected" && // verbosity[0] != "edit" && // verbosity[0] != "special" && // - verbosity[0] != "project") // + verbosity[0] != "project" && // + verbosity[0] != "sync") // { verbosity.clear (); diff --git a/src/commands/CmdCustom.cpp b/src/commands/CmdCustom.cpp index a4292b465..4c31305f7 100644 --- a/src/commands/CmdCustom.cpp +++ b/src/commands/CmdCustom.cpp @@ -145,9 +145,11 @@ int CmdCustom::execute (std::string& output) // Adjust for fluff in the output. if (maxlines) - maxlines -= (context.verbose ("blank") ? 1 : 0) - + table_header - + 1; // "X tasks shown ..." + maxlines -= table_header + + (context.verbose ("blank") ? 1 : 0) + + (context.verbose ("footnote") ? context.footnotes.size () : 0) + + (context.verbose ("affected") ? 1 : 0) + + context.config.getInteger ("reserved.lines"); // For prompt, etc. // Render. std::stringstream out; @@ -183,6 +185,7 @@ int CmdCustom::execute (std::string& output) rc = 1; } + feedback_backlog (); context.tdb2.commit (); output = out.str (); return rc; diff --git a/src/commands/CmdShow.cpp b/src/commands/CmdShow.cpp index 270149a36..fd58b004a 100644 --- a/src/commands/CmdShow.cpp +++ b/src/commands/CmdShow.cpp @@ -178,6 +178,7 @@ int CmdShow::execute (std::string& output) " recurrence.indicator" " recurrence.limit" " regex" + " reserved.lines" " row.padding" " rule.precedence.color" " search.case.sensitive" diff --git a/src/commands/CmdSync.cpp b/src/commands/CmdSync.cpp index b36b39fb4..5db7d2377 100644 --- a/src/commands/CmdSync.cpp +++ b/src/commands/CmdSync.cpp @@ -60,6 +60,9 @@ int CmdSync::execute (std::string& output) // Obtain credentials. std::string credentials_string = context.config.get ("taskd.credentials"); + if (credentials_string == "") + throw std::string (STRING_CMD_SYNC_BAD_CRED); + std::vector credentials; split (credentials, credentials_string, "/"); if (credentials.size () != 3) diff --git a/src/feedback.cpp b/src/feedback.cpp index 7a24650bf..229813632 100644 --- a/src/feedback.cpp +++ b/src/feedback.cpp @@ -415,6 +415,25 @@ void feedback_unblocked (const Task& task) } } +/////////////////////////////////////////////////////////////////////////////// +void feedback_backlog () +{ + if (context.config.get ("taskd.server") != "" && + context.verbose ("sync")) + { + std::vector lines = context.tdb2.backlog.get_lines (); + std::vector ::iterator line; + for (line = lines.begin (); line != lines.end (); ++line) + { + if ((*line)[0] == '[') + { + context.footnote ("There are local changes. Sync required."); + break; + } + } + } +} + /////////////////////////////////////////////////////////////////////////////// std::string onProjectChange (Task& task, bool scope /* = true */) { diff --git a/src/main.h b/src/main.h index 10fc6afdc..a1efbed72 100644 --- a/src/main.h +++ b/src/main.h @@ -76,6 +76,7 @@ void feedback_affected (const std::string&, int); void feedback_affected (const std::string&, const Task&); void feedback_special_tags (const Task&, const std::string&); void feedback_unblocked (const Task&); +void feedback_backlog (); std::string onProjectChange (Task&, bool scope = true); std::string onProjectChange (Task&, Task&); std::string onExpiration (Task&); diff --git a/test/limit.t b/test/limit.t index 2250d4fd4..728d24afe 100755 --- a/test/limit.t +++ b/test/limit.t @@ -79,8 +79,19 @@ like ($output, qr/^30 tasks$/ms, 'limited to 0 - unlimited'); $output = qx{../src/task rc:limit.rc ls limit:3 2>&1}; like ($output, qr/^30 tasks, 3 shown$/ms, 'limited to 3'); +# Default height is 24 lines: +# - header +# - blank +# - labels +# - underline +# - (data) +# - blank +# - affected +# - reserved.lines +# ------------ +# = 17 lines $output = qx{../src/task rc:limit.rc ls limit:page 2>&1}; -like ($output, qr/^30 tasks, truncated to 18 lines$/ms, 'limited to page'); +like ($output, qr/^30 tasks, truncated to 17 lines$/ms, 'limited to page'); # Cleanup. unlink qw(pending.data completed.data undo.data backlog.data limit.rc);