Expression

- Added configurable 'abbreviation.minimum' (default:2) setting to
  control how auto-completion works.
This commit is contained in:
Paul Beckingham 2011-07-20 10:48:59 -04:00
parent a6fadaee67
commit 197524a5fc
16 changed files with 139 additions and 52 deletions

View file

@ -27,6 +27,7 @@
#define L10N // Localization complete.
#include <iostream> // TODO Remove.
#include <iomanip>
#include <sstream>
#include <time.h>
@ -175,17 +176,18 @@ void Date::toMDY (int& m, int& d, int& y)
}
////////////////////////////////////////////////////////////////////////////////
const std::string Date::toString (const std::string& format /*= "m/d/Y" */) const
const std::string Date::toString (
const std::string& format /*= "m/d/Y" */) const
{
// Making this local copy seems to fix a bug. Remove the local copy and you'll
// see segmentation faults and all kinds of gibberish.
// Making this local copy seems to fix a bug. Remove the local copy and
// you'll see segmentation faults and all kinds of gibberish.
std::string localFormat = format;
char buffer[12];
std::string formatted;
for (unsigned int i = 0; i < localFormat.length (); ++i)
{
char c = localFormat[i];
int c = localFormat[i];
switch (c)
{
case 'm': sprintf (buffer, "%d", this->month ()); break;
@ -794,8 +796,9 @@ bool Date::isRelativeDate (const std::string& input)
supported.push_back ("later");
supported.push_back ("someday");
// Hard-coded 3, despite rc.abbreviation.minimum.
std::vector <std::string> matches;
if (autoComplete (in, supported, matches) == 1)
if (autoComplete (in, supported, matches, 3) == 1)
{
std::string found = matches[0];