#include <chat.h>
Classes | |
struct | HistoryEntry |
Public Types | |
enum | CursorOp { CURSOROP_MOVE , CURSOROP_SELECT , CURSOROP_DELETE } |
enum | CursorOpDir { CURSOROP_DIR_LEFT , CURSOROP_DIR_RIGHT } |
enum | CursorOpScope { CURSOROP_SCOPE_CHARACTER , CURSOROP_SCOPE_WORD , CURSOROP_SCOPE_LINE , CURSOROP_SCOPE_SELECTION } |
Public Member Functions | |
ChatPrompt (const std::wstring &prompt, u32 history_limit) | |
~ChatPrompt ()=default | |
void | input (wchar_t ch) |
void | input (const std::wstring &str) |
void | addToHistory (const std::wstring &line) |
std::wstring | getLine () const |
std::wstring | getSelection () const |
void | clear () |
std::wstring | replace (const std::wstring &line) |
void | historyPrev () |
void | historyNext () |
void | nickCompletion (const std::set< std::string > &names, bool backwards) |
void | reformat (u32 cols) |
std::wstring | getVisiblePortion () const |
s32 | getVisibleCursorPosition () const |
s32 | getCursorLength () const |
void | cursorOperation (CursorOp op, CursorOpDir dir, CursorOpScope scope) |
Protected Member Functions | |
const std::wstring & | getLineRef () const |
std::wstring & | makeLineRef () |
void | clampView () |
Private Attributes | |
std::wstring | m_prompt = L"" |
std::wstring | m_line = L"" |
std::vector< HistoryEntry > | m_history |
u32 | m_history_index = 0 |
u32 | m_history_limit |
s32 | m_cols = 0 |
s32 | m_view = 0 |
s32 | m_cursor = 0 |
s32 | m_cursor_len = 0 |
s32 | m_nick_completion_start = 0 |
s32 | m_nick_completion_end = 0 |
enum ChatPrompt::CursorOp |
ChatPrompt::ChatPrompt | ( | const std::wstring & | prompt, |
u32 | history_limit ) |
|
default |
void ChatPrompt::addToHistory | ( | const std::wstring & | line | ) |
References getLine(), m_history, m_history_index, m_history_limit, and m_line.
Referenced by GUIChatConsole::OnEvent(), and GUIChatConsole::replaceAndAddToHistory().
|
protected |
References getLineRef(), m_cols, m_cursor, m_view, MYMAX, and MYMIN.
Referenced by cursorOperation(), historyNext(), historyPrev(), input(), input(), nickCompletion(), reformat(), and replace().
void ChatPrompt::clear | ( | ) |
References m_cursor, m_nick_completion_end, m_nick_completion_start, m_view, and makeLineRef().
void ChatPrompt::cursorOperation | ( | CursorOp | op, |
CursorOpDir | dir, | ||
CursorOpScope | scope ) |
References clampView(), CURSOROP_DELETE, CURSOROP_DIR_RIGHT, CURSOROP_MOVE, CURSOROP_SCOPE_CHARACTER, CURSOROP_SCOPE_LINE, CURSOROP_SCOPE_SELECTION, CURSOROP_SCOPE_WORD, CURSOROP_SELECT, dir(), getLineRef(), m_cursor, m_cursor_len, m_nick_completion_end, m_nick_completion_start, makeLineRef(), MYMAX, and MYMIN.
Referenced by GUIChatConsole::OnEvent().
|
inline |
References m_cursor_len.
Referenced by GUIChatConsole::drawPrompt(), and GUIChatConsole::OnEvent().
|
inline |
References getLineRef().
Referenced by addToHistory(), GUIChatConsole::OnEvent(), replace(), and GUIChatConsole::replaceAndAddToHistory().
|
protected |
References m_history, m_history_index, and m_line.
Referenced by clampView(), cursorOperation(), getLine(), getSelection(), getVisiblePortion(), historyNext(), historyPrev(), nickCompletion(), and reformat().
|
inline |
References getLineRef(), m_cursor, and m_cursor_len.
Referenced by GUIChatConsole::OnEvent(), and GUIChatConsole::updatePrimarySelection().
s32 ChatPrompt::getVisibleCursorPosition | ( | ) | const |
References m_cursor, m_prompt, and m_view.
Referenced by GUIChatConsole::drawPrompt().
std::wstring ChatPrompt::getVisiblePortion | ( | ) | const |
References getLineRef(), m_cols, m_prompt, and m_view.
Referenced by GUIChatConsole::drawPrompt().
void ChatPrompt::historyNext | ( | ) |
References clampView(), getLineRef(), m_cursor, m_history, m_history_index, m_nick_completion_end, m_nick_completion_start, and m_view.
Referenced by GUIChatConsole::OnEvent().
void ChatPrompt::historyPrev | ( | ) |
References clampView(), getLineRef(), m_cursor, m_history_index, m_nick_completion_end, m_nick_completion_start, and m_view.
Referenced by GUIChatConsole::OnEvent().
void ChatPrompt::input | ( | const std::wstring & | str | ) |
References clampView(), m_cursor, m_nick_completion_end, m_nick_completion_start, and makeLineRef().
void ChatPrompt::input | ( | wchar_t | ch | ) |
References clampView(), m_cursor, m_nick_completion_end, m_nick_completion_start, and makeLineRef().
Referenced by GUIChatConsole::OnEvent().
|
protected |
References m_history, m_history_index, and m_line.
Referenced by clear(), cursorOperation(), input(), input(), nickCompletion(), and replace().
void ChatPrompt::nickCompletion | ( | const std::set< std::string > & | names, |
bool | backwards ) |
References clampView(), getLineRef(), m_cursor, m_nick_completion_end, m_nick_completion_start, makeLineRef(), str_equal(), str_starts_with(), and utf8_to_wide().
Referenced by GUIChatConsole::OnEvent().
void ChatPrompt::reformat | ( | u32 | cols | ) |
References clampView(), getLineRef(), m_cols, m_cursor, m_prompt, and m_view.
Referenced by ChatBackend::reformat().
std::wstring ChatPrompt::replace | ( | const std::wstring & | line | ) |
References clampView(), getLine(), m_cursor, m_nick_completion_end, m_nick_completion_start, m_view, and makeLineRef().
Referenced by GUIChatConsole::OnEvent(), and GUIChatConsole::replaceAndAddToHistory().
|
private |
Referenced by clampView(), getVisiblePortion(), and reformat().
|
private |
Referenced by clampView(), clear(), cursorOperation(), getSelection(), getVisibleCursorPosition(), historyNext(), historyPrev(), input(), input(), nickCompletion(), reformat(), and replace().
|
private |
Referenced by cursorOperation(), getCursorLength(), and getSelection().
|
private |
Referenced by addToHistory(), getLineRef(), historyNext(), and makeLineRef().
|
private |
Referenced by addToHistory(), getLineRef(), historyNext(), historyPrev(), and makeLineRef().
|
private |
Referenced by addToHistory().
|
private |
Referenced by addToHistory(), getLineRef(), and makeLineRef().
|
private |
Referenced by clear(), cursorOperation(), historyNext(), historyPrev(), input(), input(), nickCompletion(), and replace().
|
private |
Referenced by clear(), cursorOperation(), historyNext(), historyPrev(), input(), input(), nickCompletion(), and replace().
|
private |
Referenced by getVisibleCursorPosition(), getVisiblePortion(), and reformat().
|
private |
Referenced by clampView(), clear(), getVisibleCursorPosition(), getVisiblePortion(), historyNext(), historyPrev(), reformat(), and replace().