editor: Always remove previous suggestions before adding new ones

9e771ac moved the Win32 ClearInput implementation into SetInputFunctions,
but broke at least GTK while doing that. 9a7d57c0d2 fixed the assertion
failure in GTK that resulted, but failed to restore the removal of the old
completions.

Fix this by folding ClearInput into SetInputFunctions in all implementations.
shapetextures
Günther Brammer 2016-01-08 04:35:16 +01:00
parent 8552b3a8f9
commit 67bf24f1e1
5 changed files with 7 additions and 30 deletions

View File

@ -573,7 +573,6 @@ void C4ConsoleGUI::AddMenuItemForPlayer(C4Player*, StdStrBuf&) {}
void C4ConsoleGUI::AddNetMenuItemForPlayer(int, StdStrBuf&) {}
void C4ConsoleGUI::AddNetMenu() {}
void C4ConsoleGUI::ToolsDlgClose() {}
void C4ConsoleGUI::ClearInput() {}
bool C4ConsoleGUI::ClearLog() {return 0;}
void C4ConsoleGUI::ClearNetMenu() {}
void C4ConsoleGUI::ClearPlayerMenu() {}

View File

@ -410,11 +410,6 @@ void C4ToolsDlg::EnableControls()
NeedPreviewUpdate();
}
void C4ConsoleGUI::ClearInput()
{
[ctrler(this).consoleCombo setStringValue:[NSString string]];
}
void C4ConsoleGUI::ClearPlayerMenu()
{
}
@ -428,6 +423,7 @@ void C4ConsoleGUI::AddNetMenuItemForPlayer(int32_t index, StdStrBuf &text)
void C4ConsoleGUI::SetInputFunctions(std::list<const char*> &functions)
{
[ctrler(this).consoleCombo setStringValue:[NSString string]];
[ctrler(this) setInputFunctions:functions];
}

View File

@ -822,7 +822,7 @@ void C4ConsoleGUI::ClearNetMenu()
state->itemNet = NULL;
}
void C4ConsoleGUI::ClearInput()
void C4ConsoleGUI::SetInputFunctions(std::list<const char*>& functions)
{
// Don't need to do anything if the GUI is not created
if(state->txtScript == NULL) return;
@ -842,21 +842,8 @@ void C4ConsoleGUI::ClearInput()
GtkListStore* store = GTK_LIST_STORE(gtk_entry_completion_get_model(completion));
g_assert(store);
gtk_list_store_clear(store);
}
void C4ConsoleGUI::SetInputFunctions(std::list<const char*>& functions)
{
if(state->txtScript == NULL) return;
GtkEntryCompletion* completion = gtk_entry_get_completion(GTK_ENTRY(state->txtScript));
if(!completion)
{
ClearInput();
completion = gtk_entry_get_completion(GTK_ENTRY(state->txtScript));
}
GtkListStore* store = GTK_LIST_STORE(gtk_entry_completion_get_model(completion));
GtkTreeIter iter;
g_assert(store);
for (std::list<const char*>::iterator it(functions.begin()); it != functions.end(); ++it)
{
const char* fn = *it;
@ -1046,7 +1033,7 @@ void C4ConsoleGUI::PropertyDlgUpdate(C4ObjectList &rSelection, bool force_functi
if (PropertyDlgObject == rSelection.GetObject() && !force_function_update) return;
PropertyDlgObject = rSelection.GetObject();
std::list<const char *> functions = ::ScriptEngine.GetFunctionNames(PropertyDlgObject);
std::list<const char *> functions = ::Console.GetScriptSuggestions(PropertyDlgObject, C4Console::MRU_Object);
GtkEntryCompletion* completion = gtk_entry_get_completion(GTK_ENTRY(state->propertydlg_entry));
GtkListStore* store;
@ -1496,7 +1483,10 @@ void C4ConsoleGUI::State::OnDestroy(GtkWidget* window, gpointer data)
void C4ConsoleGUI::State::OnScriptEntry(GtkWidget* entry, gpointer data)
{
C4ConsoleGUI::State* state = static_cast<C4ConsoleGUI::State*>(data);
Console.In(gtk_entry_get_text(GTK_ENTRY(state->txtScript)));
const char * text = gtk_entry_get_text(GTK_ENTRY(state->txtScript));
::Console.RegisterRecentInput(text, C4Console::MRU_Scenario);
::Console.In(text);
::Console.UpdateInputCtrl();
gtk_editable_select_region(GTK_EDITABLE(state->txtScript), 0, -1);
}

View File

@ -86,7 +86,6 @@ public:
void AddNetMenu();
void ClearNetMenu();
void AddNetMenuItemForPlayer(int32_t index, StdStrBuf &text);
void ClearInput();
void ClearPlayerMenu();
void SetInputFunctions(std::list<const char*> &functions);

View File

@ -909,13 +909,6 @@ void C4ConsoleGUI::ClearPlayerMenu()
while (DeleteMenu(hMenu,1,MF_BYPOSITION));
}
void C4ConsoleGUI::ClearInput()
{
HWND hCombo = GetDlgItem(hWindow,IDC_COMBOINPUT);
// Clear
SendMessage(hCombo,CB_RESETCONTENT,0,0);
}
/*
void C4ConsoleGUI::ClearPropertyDlg(C4PropertyDlg *dlg)
{