InputText: Added BufTextLen in ImGuiTextEditCallbackData. Requesting user to maintain it. Zero-ing structure properly before use. (#541)

This commit is contained in:
ocornut
2016-03-02 23:34:29 +01:00
parent 17d3c202ac
commit cf12bc7dea
3 changed files with 27 additions and 21 deletions

View File

@ -1888,6 +1888,7 @@ struct ExampleAppConsole
Commands.push_back("HISTORY");
Commands.push_back("CLEAR");
Commands.push_back("CLASSIFY"); // "classify" is here to provide an example of "C"+[tab] completing to "CL" and displaying matches.
AddLog("Welcome to ImGui!");
}
~ExampleAppConsole()
{
@ -2128,9 +2129,8 @@ struct ExampleAppConsole
// A better implementation would preserve the data on the current input line along with cursor position.
if (prev_history_pos != HistoryPos)
{
snprintf(data->Buf, data->BufSize, "%s", (HistoryPos >= 0) ? History[HistoryPos] : "");
data->CursorPos = data->SelectionStart = data->SelectionEnd = data->BufTextLen = (int)snprintf(data->Buf, data->BufSize, "%s", (HistoryPos >= 0) ? History[HistoryPos] : "");
data->BufDirty = true;
data->CursorPos = data->SelectionStart = data->SelectionEnd = (int)strlen(data->Buf);
}
}
}