Skip to content

Commit

Permalink
Improved Ctrl+Tab completion
Browse files Browse the repository at this point in the history
  • Loading branch information
nickgammon committed Aug 10, 2010
1 parent a3cbe39 commit 1d4b17d
Show file tree
Hide file tree
Showing 7 changed files with 520 additions and 448 deletions.
19 changes: 15 additions & 4 deletions dialogs/CompleteWordDlg.cpp
Expand Up @@ -51,7 +51,7 @@ END_MESSAGE_MAP()

static const char * sNoMatches = "(no matches)";

extern const char * sFunctions [1];
extern tInternalFunctionsTable InternalFunctionsTable [1];

void CCompleteWordDlg::ReloadList ()
{
Expand All @@ -72,15 +72,15 @@ void CCompleteWordDlg::ReloadList ()

if (m_bFunctions)
{
for (int i = 0; sFunctions [i] [0]; i++)
for (int i = 0; InternalFunctionsTable [i].sFunction [0]; i++)
{
strFunction = sFunctions [i];
strFunction = InternalFunctionsTable [i].sFunction;
strFunction.MakeLower ();
strFunction = strFunction.Left (iFilterLength);

if (m_strFilter == strFunction)
{
m_ctlFunctions.AddString (sFunctions [i]);
m_ctlFunctions.AddString (InternalFunctionsTable [i].sFunction);
iCount++;
}

Expand Down Expand Up @@ -192,6 +192,17 @@ void CCompleteWordDlg::OnOK()
// can't return our "no matches" string
if (m_strResult == sNoMatches)
m_strResult.Empty ();
else
{
for (int i = 0; InternalFunctionsTable [i].sFunction [0]; i++)
{
if (m_strResult == InternalFunctionsTable [i].sFunction)
{
m_strArgs = InternalFunctionsTable [i].sArgs;
break;
} // end if function found
} // end for
} // not "no matches"

CDialog::OnOK();
}
1 change: 1 addition & 0 deletions dialogs/CompleteWordDlg.h
Expand Up @@ -25,6 +25,7 @@ class CCompleteWordDlg : public CDialog
const char * m_sFunctionsPtr;
int m_nFunctions;
CString m_strResult;
CString m_strArgs;
CString m_strFilter;
CPoint m_pt; // where to put it

Expand Down
8 changes: 4 additions & 4 deletions dialogs/FunctionListDlg.cpp
Expand Up @@ -51,7 +51,7 @@ BEGIN_MESSAGE_MAP(CFunctionListDlg, CDialog)

END_MESSAGE_MAP()

extern const char * sFunctions [1];
extern tInternalFunctionsTable InternalFunctionsTable [1];

BOOL CFunctionListDlg::ReloadList ()
{
Expand All @@ -69,14 +69,14 @@ BOOL CFunctionListDlg::ReloadList ()

int nItem = 0;

for (int i = 0; sFunctions [i] [0]; i++)
for (int i = 0; InternalFunctionsTable [i].sFunction [0]; i++)
{
strFunction = sFunctions [i];
strFunction = InternalFunctionsTable [i].sFunction;
strFunction.MakeLower ();

if (m_strFilter.IsEmpty () || strFunction.Find (m_strFilter) != -1)
{
m_ctlFunctions.InsertItem (nItem, sFunctions [i]);
m_ctlFunctions.InsertItem (nItem, InternalFunctionsTable [i].sFunction);

// select the exact match, if any (so, if they highlight world.Note then it is selected)

Expand Down

1 comment on commit 1d4b17d

@nickgammon
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should read: Shift+Tab

Please sign in to comment.