diff --git a/src/Context.cpp b/src/Context.cpp index c61de58de..3c2883ecf 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -593,6 +593,32 @@ const std::vector Context::getCommands () const return output; } +//////////////////////////////////////////////////////////////////////////////// +// A value of zero mean unlimited. +// A value of 'page' means however many screen lines there are. +// A value of a positive integer is a row/task limit. +void Context::getLimits (int& rows, int& lines) +{ + rows = 0; + lines = 0; + + // This is an integer specified as a filter (limit:10). + std::string limit = parser.getLimit (); + if (limit != "") + { + if (limit == "page") + { + rows = 0; + lines = getHeight (); + } + else + { + rows = (int) strtol (limit.c_str (), NULL, 10); + lines = 0; + } + } +} + //////////////////////////////////////////////////////////////////////////////// // The 'Task' object, among others, is shared between projects. To make this // easier, it has been decoupled from Context. diff --git a/src/Context.h b/src/Context.h index 24d5bef42..a532ac6ad 100644 --- a/src/Context.h +++ b/src/Context.h @@ -59,6 +59,7 @@ public: const std::vector getColumns () const; const std::vector getCommands () const; + void getLimits (int&, int&); bool color (); // TTY or ? bool verbose (const std::string&); // Verbosity control