mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Eliminated ncurses
- Removed autoconf ncurses detection. - Modified man pages. - Inserted vitapi replacement code. - Cached terminal size values for reuse. - Modified packaging info for OSX. - Removed -lncurses from unit test makefile. - Removed obsolete taskrc example. - Modified (simplified) source build instructions.
This commit is contained in:
parent
551c4b99c4
commit
c73f131f32
22 changed files with 60 additions and 654 deletions
|
@ -115,13 +115,6 @@ static int api_task_feature (lua_State* L)
|
|||
#endif
|
||||
}
|
||||
|
||||
else if (name == "ncurses")
|
||||
{
|
||||
#ifdef HAVE_NCURSES
|
||||
value = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
else if (name == "lua")
|
||||
value = true;
|
||||
|
||||
|
|
|
@ -63,8 +63,8 @@ std::string Config::defaults =
|
|||
"gc=on # Garbage-collect data files - DO NOT CHANGE unless you are sure\n"
|
||||
"\n"
|
||||
"# Terminal\n"
|
||||
"curses=on # Use ncurses library to determine terminal width\n"
|
||||
"defaultwidth=80 # Without ncurses, assumed width\n"
|
||||
"curses=on # Detects terminal width\n"
|
||||
"defaultwidth=80 # Without detection, assumed width\n"
|
||||
"#editor=vi # Preferred text editor\n"
|
||||
"\n"
|
||||
"# Miscellaneous\n"
|
||||
|
|
|
@ -56,6 +56,8 @@ Context::Context ()
|
|||
, var_overrides ("")
|
||||
, cmd ()
|
||||
, inShadow (false)
|
||||
, terminal_width (0)
|
||||
, terminal_height (0)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -99,6 +99,9 @@ public:
|
|||
std::vector <std::string> footnotes;
|
||||
std::vector <std::string> debugMessages;
|
||||
bool inShadow;
|
||||
|
||||
int terminal_width;
|
||||
int terminal_height;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -45,10 +45,6 @@
|
|||
#include "../auto.h"
|
||||
#include "Transport.h"
|
||||
|
||||
#ifdef HAVE_LIBNCURSES
|
||||
#include <ncurses.h>
|
||||
#endif
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -836,10 +832,6 @@ int handleVersion (std::string& outs)
|
|||
<< "unknown"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBNCURSES
|
||||
<< "-ncurses"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBREADLINE
|
||||
<< "-readline"
|
||||
#endif
|
||||
|
|
|
@ -43,10 +43,6 @@
|
|||
#include "util.h"
|
||||
#include "main.h"
|
||||
|
||||
#ifdef HAVE_LIBNCURSES
|
||||
#include <ncurses.h>
|
||||
#endif
|
||||
|
||||
extern Context context;
|
||||
static std::vector <std::string> customReports;
|
||||
|
||||
|
|
16
src/diag.cpp
16
src/diag.cpp
|
@ -47,10 +47,6 @@ extern "C"
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBNCURSES
|
||||
#include <ncurses.h>
|
||||
#endif
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -118,18 +114,6 @@ void handleDiagnostics (std::string& outs)
|
|||
|
||||
std::cout << "[1mLibraries[0m\n";
|
||||
|
||||
// NCurses.
|
||||
std::cout << " NCurses: "
|
||||
#ifdef HAVE_LIBNCURSES
|
||||
<< NCURSES_VERSION
|
||||
<< " ("
|
||||
<< NCURSES_VERSION_PATCH
|
||||
<< ")"
|
||||
#else
|
||||
<< "n/a"
|
||||
#endif
|
||||
<< "\n";
|
||||
|
||||
std::cout << " Readline: "
|
||||
#ifdef HAVE_LIBREADLINE
|
||||
<< std::setbase (16) << RL_READLINE_VERSION
|
||||
|
|
|
@ -28,7 +28,8 @@
|
|||
//#include <iostream>
|
||||
#include <sstream>
|
||||
//#include <pwd.h>
|
||||
//#include <stdio.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/ioctl.h>
|
||||
//#include <stdlib.h>
|
||||
//#include <string.h>
|
||||
#include "Context.h"
|
||||
|
@ -38,134 +39,41 @@
|
|||
#include "i18n.h"
|
||||
#include "../auto.h"
|
||||
|
||||
#ifdef HAVE_LIBNCURSES
|
||||
#include <ncurses.h>
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int Context::interactive ()
|
||||
{
|
||||
#ifdef HAVE_LIBNCURSES
|
||||
|
||||
// TODO init ncurses
|
||||
// TODO create worker thread
|
||||
// TODO create refresh thread
|
||||
|
||||
// TODO join refresh thread
|
||||
// TODO join worker thread
|
||||
// TODO take down ncurses
|
||||
|
||||
// throw std::string ("unimplemented Context::interactive");
|
||||
|
||||
// Fake interactive teaser...
|
||||
#ifdef FEATURE_NCURSES_COLS
|
||||
initscr ();
|
||||
int width = COLS;
|
||||
int height = LINES;
|
||||
#else
|
||||
WINDOW* w = initscr ();
|
||||
int width = w->_maxx + 1;
|
||||
int height = w->_maxy + 1;
|
||||
#endif
|
||||
|
||||
(void) nonl ();
|
||||
(void) cbreak ();
|
||||
|
||||
start_color ();
|
||||
init_pair (1, COLOR_WHITE, COLOR_BLUE);
|
||||
init_pair (2, COLOR_WHITE, COLOR_RED);
|
||||
init_pair (3, COLOR_CYAN, COLOR_BLUE);
|
||||
|
||||
// Process commands.
|
||||
std::string command = "";
|
||||
int c;
|
||||
while (command != "quit")
|
||||
{
|
||||
// Render title.
|
||||
std::string title = "taskwarrior 3.0.0";
|
||||
while ((int) title.length () < width)
|
||||
title += " ";
|
||||
|
||||
bkgdset (COLOR_PAIR (1));
|
||||
mvprintw (0, 0, title.c_str ());
|
||||
|
||||
bkgdset (COLOR_PAIR (2));
|
||||
int line = height / 2;
|
||||
mvprintw (line, width / 2 - 24, " I n t e r a c t i v e t a s k w a r r i o r ");
|
||||
mvprintw (line + 1, width / 2 - 24, " Coming in version 3.0.0 ");
|
||||
|
||||
std::string footer = "Press 'q' to quit.";
|
||||
while ((int) footer.length () < width)
|
||||
footer = " " + footer;
|
||||
|
||||
bkgdset (COLOR_PAIR (3));
|
||||
mvprintw (height - 1, 0, footer.c_str ());
|
||||
|
||||
move (1, 0);
|
||||
refresh ();
|
||||
|
||||
if ((c = getch ()) != ERR)
|
||||
{
|
||||
// 'Esc' and 'Enter' clear the accumulated commands.
|
||||
// TODO Looks like \n is not preserved by getch.
|
||||
if (c == 033 || c == '\n')
|
||||
{
|
||||
command = "";
|
||||
}
|
||||
|
||||
else if (c == 'q')
|
||||
{
|
||||
command = "quit";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
endwin ();
|
||||
return 0;
|
||||
|
||||
#else
|
||||
|
||||
throw stringtable.get (INTERACTIVE_NO_NCURSES,
|
||||
"Interactive taskwarrior is only available when built "
|
||||
"with ncurses support.");
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int Context::getWidth ()
|
||||
{
|
||||
// Determine window size, and set table accordingly.
|
||||
// Determine window size.
|
||||
int width = config.getInteger ("defaultwidth");
|
||||
|
||||
#ifdef HAVE_LIBNCURSES
|
||||
if (config.getBoolean ("curses"))
|
||||
{
|
||||
#ifdef FEATURE_NCURSES_COLS
|
||||
initscr ();
|
||||
width = COLS;
|
||||
#else
|
||||
WINDOW* w = initscr ();
|
||||
width = w->_maxx + 1;
|
||||
#endif
|
||||
endwin ();
|
||||
|
||||
std::stringstream out;
|
||||
out << "Context::getWidth: ncurses determined width of " << width << " characters";
|
||||
debug (out.str ());
|
||||
}
|
||||
else
|
||||
debug ("Context::getWidth: ncurses available but disabled.");
|
||||
#else
|
||||
std::stringstream out;
|
||||
out << "Context::getWidth: no ncurses, using width of " << width << " characters";
|
||||
debug (out.str ());
|
||||
#endif
|
||||
|
||||
// A zero width value means 'infinity', which is approximated here by 2^16.
|
||||
if (width == 0)
|
||||
width = 65536;
|
||||
return 65536;
|
||||
|
||||
if (config.getBoolean ("curses"))
|
||||
{
|
||||
if (terminal_width == 0 &&
|
||||
terminal_height == 0)
|
||||
{
|
||||
unsigned short buff[4];
|
||||
if (ioctl (fileno(stdout), TIOCGWINSZ, &buff) != -1)
|
||||
{
|
||||
terminal_height = buff[0];
|
||||
terminal_width = buff[1];
|
||||
|
||||
std::stringstream out;
|
||||
out << "Context::getWidth: determined width of " << width << " characters";
|
||||
debug (out.str ());
|
||||
}
|
||||
}
|
||||
|
||||
width = terminal_width;
|
||||
}
|
||||
|
||||
return width;
|
||||
}
|
||||
|
@ -173,32 +81,27 @@ int Context::getWidth ()
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
int Context::getHeight ()
|
||||
{
|
||||
// Determine window size, and set table accordingly.
|
||||
int height = 25; // TODO Is there a better number?
|
||||
int height = 24;
|
||||
|
||||
#ifdef HAVE_LIBNCURSES
|
||||
if (config.getBoolean ("curses"))
|
||||
{
|
||||
#ifdef FEATURE_NCURSES_COLS
|
||||
initscr ();
|
||||
height = LINES;
|
||||
#else
|
||||
WINDOW* w = initscr ();
|
||||
height = w->_maxy + 1;
|
||||
#endif
|
||||
endwin ();
|
||||
if (terminal_width == 0 &&
|
||||
terminal_height == 0)
|
||||
{
|
||||
unsigned short buff[4];
|
||||
if (ioctl (fileno(stdout), TIOCGWINSZ, &buff) != -1)
|
||||
{
|
||||
terminal_height = buff[0];
|
||||
terminal_width = buff[1];
|
||||
|
||||
std::stringstream out;
|
||||
out << "Context::getHeight: ncurses determined height of " << height << " characters";
|
||||
debug (out.str ());
|
||||
std::stringstream out;
|
||||
out << "Context::getWidth: determined height of " << terminal_height << " characters";
|
||||
debug (out.str ());
|
||||
}
|
||||
}
|
||||
|
||||
height = terminal_height;
|
||||
}
|
||||
else
|
||||
debug ("Context::getHeight: ncurses available but disabled.");
|
||||
#else
|
||||
std::stringstream out;
|
||||
out << "Context::getHeight: no ncurses, using height of " << height << " characters";
|
||||
debug (out.str ());
|
||||
#endif
|
||||
|
||||
return height;
|
||||
}
|
||||
|
|
|
@ -44,10 +44,6 @@
|
|||
#include "util.h"
|
||||
#include "main.h"
|
||||
|
||||
#ifdef HAVE_LIBNCURSES
|
||||
#include <ncurses.h>
|
||||
#endif
|
||||
|
||||
// Global context for use by all.
|
||||
extern Context context;
|
||||
|
||||
|
|
|
@ -47,10 +47,6 @@
|
|||
#include <util.h>
|
||||
#include <main.h>
|
||||
|
||||
#ifdef HAVE_LIBNCURSES
|
||||
#include <ncurses.h>
|
||||
#endif
|
||||
|
||||
static void countTasks (const std::vector <Task>&, const std::string&, const std::string&, int&, int&);
|
||||
|
||||
extern Context context;
|
||||
|
|
|
@ -3,7 +3,7 @@ PROJECT = t.t tdb.t date.t duration.t t.benchmark.t text.t autocomplete.t \
|
|||
cmd.t util.t color.t list.t path.t file.t directory.t grid.t rx.t \
|
||||
taskmod.t sensor.t rectangle.t tree.t tree2.t lisp.t uri.t
|
||||
CFLAGS = -I. -I.. -I../.. -Wall -pedantic -ggdb3 -fno-rtti
|
||||
LFLAGS = -L/usr/local/lib -lpthread -lncurses -llua
|
||||
LFLAGS = -L/usr/local/lib -lpthread -llua
|
||||
OBJECTS = ../t-TDB.o ../t-Task.o ../t-text.o ../t-Date.o ../t-Table.o \
|
||||
../t-Duration.o ../t-util.o ../t-Config.o ../t-Sequence.o ../t-Att.o \
|
||||
../t-Cmd.o ../t-Record.o ../t-StringTable.o ../t-Subst.o \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue