(svn r25092) -Codechange: Deduplicate keyboard handling between console and editboxes.

This commit is contained in:
frosch
2013-03-17 13:05:45 +00:00
parent b83cadfc49
commit 337460249d
6 changed files with 71 additions and 106 deletions

View File

@@ -15,6 +15,18 @@
#include "string_type.h"
#include "strings_type.h"
/**
* Return values for Textbuf::HandleKeypress
*/
enum HandleKeyPressResult
{
HKPR_EDITING, ///< Textbuf content changed.
HKPR_CURSOR, ///< Non-text change, e.g. cursor position.
HKPR_CONFIRM, ///< Return or enter key pressed.
HKPR_CANCEL, ///< Escape key pressed.
HKPR_NOT_HANDLED, ///< Key does not affect editboxes.
};
/** Helper/buffer for input fields. */
struct Textbuf {
CharSetFilter afilter; ///< Allowed characters
@@ -43,6 +55,8 @@ struct Textbuf {
bool DeleteChar(uint16 keycode);
bool MovePos(uint16 keycode);
HandleKeyPressResult HandleKeyPress(uint16 key, uint16 keycode);
bool HandleCaret();
void UpdateSize();