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

@ -33,6 +33,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <Context.h>
#include <text.h>
#include <util.h>
#include <i18n.h>
@ -91,6 +92,8 @@ static const char* durations[] =
#define NUM_DURATIONS (sizeof (durations) / sizeof (durations[0]))
extern Context context;
////////////////////////////////////////////////////////////////////////////////
Duration::Duration ()
: mSecs (0)
@ -339,7 +342,10 @@ bool Duration::valid (const std::string& input)
supported.push_back (durations[i]);
std::vector <std::string> matches;
if (autoComplete (units, supported, matches) == 1)
if (autoComplete (units,
supported,
matches,
context.config.getInteger ("abbreviation.minimum")) == 1)
return true;
return false;
@ -376,7 +382,10 @@ void Duration::parse (const std::string& input)
mSecs = 0;
std::vector <std::string> matches;
if (autoComplete (units, supported, matches) == 1)
if (autoComplete (units,
supported,
matches,
context.config.getInteger ("abbreviation.minimum")) == 1)
{
std::string match = matches[0];