mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-19 19:03:07 +02:00
Interactive - stub
- Added stub code for the interactive version of task.
This commit is contained in:
parent
e9c45aab85
commit
bc13f0be48
4 changed files with 82 additions and 3 deletions
|
@ -18,7 +18,7 @@
|
||||||
105 Inverted sequence range high-low
|
105 Inverted sequence range high-low
|
||||||
106 ID Range too large
|
106 ID Range too large
|
||||||
107 Not a sequence.
|
107 Not a sequence.
|
||||||
|
108 Interactive task is only available when built with ncurses support.
|
||||||
|
|
||||||
# 2xx Commands
|
# 2xx Commands
|
||||||
200 active
|
200 active
|
||||||
|
|
|
@ -36,6 +36,10 @@
|
||||||
#include "i18n.h"
|
#include "i18n.h"
|
||||||
#include "../auto.h"
|
#include "../auto.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBNCURSES
|
||||||
|
#include <ncurses.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Context::Context ()
|
Context::Context ()
|
||||||
: config ()
|
: config ()
|
||||||
|
@ -181,6 +185,8 @@ int Context::run ()
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int Context::interactive ()
|
int Context::interactive ()
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_LIBNCURSES
|
||||||
|
|
||||||
// TODO init ncurses
|
// TODO init ncurses
|
||||||
// TODO create worker thread
|
// TODO create worker thread
|
||||||
// TODO create refresh thread
|
// TODO create refresh thread
|
||||||
|
@ -189,8 +195,76 @@ int Context::interactive ()
|
||||||
// TODO join worker thread
|
// TODO join worker thread
|
||||||
// TODO take down ncurses
|
// TODO take down ncurses
|
||||||
|
|
||||||
throw std::string ("unimplemented Context::interactive");
|
// throw std::string ("unimplemented Context::interactive");
|
||||||
|
|
||||||
|
// Fake interactive teaser...
|
||||||
|
WINDOW* w = initscr ();
|
||||||
|
int width = w->_maxx + 1;
|
||||||
|
int height = w->_maxy + 1;
|
||||||
|
|
||||||
|
(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 = "task 2.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 - 14, " I n t e r a c t i v e t a s k ");
|
||||||
|
mvprintw (line + 1, width / 2 - 14, " Coming in version 2.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;
|
return 0;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
throw stringtable (INTERACTIVE_NO_NCURSES,
|
||||||
|
"Interactive task is only available when built with ncurses "
|
||||||
|
"support.");
|
||||||
|
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -40,6 +40,8 @@
|
||||||
#define SEQUENCE_RANGE_MAX 106
|
#define SEQUENCE_RANGE_MAX 106
|
||||||
#define SEQUENCE_NOT_A_SEQUENCE 107
|
#define SEQUENCE_NOT_A_SEQUENCE 107
|
||||||
|
|
||||||
|
#define INTERACTIVE_NO_NCURSES 108
|
||||||
|
|
||||||
// 2xx Commands
|
// 2xx Commands
|
||||||
#define CMD_ACTIVE 200
|
#define CMD_ACTIVE 200
|
||||||
#define CMD_ADD 201
|
#define CMD_ADD 201
|
||||||
|
|
|
@ -302,7 +302,10 @@ int main (int argc, char** argv)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
context.initialize (argc, argv);
|
context.initialize (argc, argv);
|
||||||
/* return */ context.run ();
|
if (context.args[0].find ("itask") != std::string::npos)
|
||||||
|
/* return */ context.interactive ();
|
||||||
|
else
|
||||||
|
/* return */ context.run ();
|
||||||
|
|
||||||
// start OBSOLETE
|
// start OBSOLETE
|
||||||
TDB tdb;
|
TDB tdb;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue