From 0f5a4434ffa8e3733dc298e286b462f80cce6ce4 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Mon, 30 May 2011 10:21:50 -0400 Subject: [PATCH] Bug #511 - Fixed bug #511, which caused display problem on Cygwin when colored output used the full width of the terminal. The 'avoidlastcolumn' configuration variable forces taskwarrior to never use the last column. --- ChangeLog | 3 +++ doc/man/taskrc.5.in | 6 ++++++ src/Config.cpp | 1 + src/commands/CmdShow.cpp | 8 ++++---- src/interactive.cpp | 6 ++++++ 5 files changed, 20 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 92107bc29..ff0355136 100644 --- a/ChangeLog +++ b/ChangeLog @@ -52,6 +52,9 @@ Cech). # Tracked Bugs, sorted by ID. + + Fixed bug #511, which caused display problem on Cygwin when colored output + used the full width of the terminal. The 'avoidlastcolumn' configuration + variable forces taskwarrior to never use the last column. + Fixed bug #594, which broke the 'all' report with a combination of bad regex handling and a formatting bug (thanks to Steve Rader). + Fixed bug #605, which gave misleading project completion percentages under diff --git a/doc/man/taskrc.5.in b/doc/man/taskrc.5.in index 50ad9d6aa..084c40bb0 100644 --- a/doc/man/taskrc.5.in +++ b/doc/man/taskrc.5.in @@ -166,6 +166,12 @@ to 80. If set to 0, is interpreted as infinite width, therefore with no word-wrapping; useful when redirecting report output to a file for subsequent manipulation. +.TP +.B avoidlastcolumn=no +Causes the width of the terminal minus one to be used as the full width. This +avoids placing color codes in the last column which can cause problems for +Cygwin users. Default value is 'no'. + .TP .B editor=vi Specifies which text editor you wish to use for when the diff --git a/src/Config.cpp b/src/Config.cpp index fd3aa6377..2aad974a9 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -65,6 +65,7 @@ std::string Config::defaults = "# Terminal\n" "detection=on # Detects terminal width\n" "defaultwidth=80 # Without detection, assumed width\n" + "avoidlastcolumn=no # Fixes Cygwin width problem\n" "#editor=vi # Preferred text editor\n" "edit.verbose=yes # Include comments in files created during task edit\n" "\n" diff --git a/src/commands/CmdShow.cpp b/src/commands/CmdShow.cpp index 2ae4194be..69f323e7a 100644 --- a/src/commands/CmdShow.cpp +++ b/src/commands/CmdShow.cpp @@ -67,10 +67,10 @@ int CmdShow::execute (const std::string&, std::string& output) // Note that there is a leading and trailing space, to make it easier to // search for whole words. std::string recognized = - " annotations bulk burndown.bias calendar.details calendar.details.report " - "calendar.holidays calendar.legend color calendar.offset " - "calendar.offset.value color.active color.due color.due.today " - "color.blocked color.burndown.done color.burndown.pending " + " annotations avoidlastcolumn bulk burndown.bias calendar.details " + "calendar.details.report calendar.holidays calendar.legend color " + "calendar.offset calendar.offset.value color.active color.due " + "color.due.today color.blocked color.burndown.done color.burndown.pending " "color.burndown.started color.overdue color.pri.H color.pri.L color.pri.M " "color.pri.none color.recurring color.tagged color.footnote color.header " "color.debug color.alternate color.calendar.today color.calendar.due " diff --git a/src/interactive.cpp b/src/interactive.cpp index cc946c971..0891f721a 100644 --- a/src/interactive.cpp +++ b/src/interactive.cpp @@ -61,6 +61,12 @@ int Context::getWidth () } width = terminal_width; + + // Ncurses does this, and perhaps we need to as well, to avoid a problem on + // Cygwin where the display goes right up to the terminal width, and causes + // and odd color wrapping problem. + if (config.getBoolean ("avoidlastcolumn")) + --width; } return width;