Luanti 5.11.0-dev
 
Loading...
Searching...
No Matches
ChatPrompt Class Reference

#include <chat.h>

+ Collaboration diagram for ChatPrompt:

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< HistoryEntrym_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
 

Member Enumeration Documentation

◆ CursorOp

Enumerator
CURSOROP_MOVE 
CURSOROP_SELECT 
CURSOROP_DELETE 

◆ CursorOpDir

Enumerator
CURSOROP_DIR_LEFT 
CURSOROP_DIR_RIGHT 

◆ CursorOpScope

Enumerator
CURSOROP_SCOPE_CHARACTER 
CURSOROP_SCOPE_WORD 
CURSOROP_SCOPE_LINE 
CURSOROP_SCOPE_SELECTION 

Constructor & Destructor Documentation

◆ ChatPrompt()

ChatPrompt::ChatPrompt ( const std::wstring & prompt,
u32 history_limit )

◆ ~ChatPrompt()

ChatPrompt::~ChatPrompt ( )
default

Member Function Documentation

◆ addToHistory()

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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clampView()

void ChatPrompt::clampView ( )
protected

References getLineRef(), m_cols, m_cursor, m_view, MYMAX, and MYMIN.

Referenced by cursorOperation(), historyNext(), historyPrev(), input(), input(), nickCompletion(), reformat(), and replace().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clear()

void ChatPrompt::clear ( )

References m_cursor, m_nick_completion_end, m_nick_completion_start, m_view, and makeLineRef().

+ Here is the call graph for this function:

◆ cursorOperation()

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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCursorLength()

s32 ChatPrompt::getCursorLength ( ) const
inline

References m_cursor_len.

Referenced by GUIChatConsole::drawPrompt(), and GUIChatConsole::OnEvent().

+ Here is the caller graph for this function:

◆ getLine()

std::wstring ChatPrompt::getLine ( ) const
inline

References getLineRef().

Referenced by addToHistory(), GUIChatConsole::OnEvent(), replace(), and GUIChatConsole::replaceAndAddToHistory().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLineRef()

const std::wstring & ChatPrompt::getLineRef ( ) const
protected

References m_history, m_history_index, and m_line.

Referenced by clampView(), cursorOperation(), getLine(), getSelection(), getVisiblePortion(), historyNext(), historyPrev(), nickCompletion(), and reformat().

+ Here is the caller graph for this function:

◆ getSelection()

std::wstring ChatPrompt::getSelection ( ) const
inline

References getLineRef(), m_cursor, and m_cursor_len.

Referenced by GUIChatConsole::OnEvent(), and GUIChatConsole::updatePrimarySelection().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getVisibleCursorPosition()

s32 ChatPrompt::getVisibleCursorPosition ( ) const

References m_cursor, m_prompt, and m_view.

Referenced by GUIChatConsole::drawPrompt().

+ Here is the caller graph for this function:

◆ getVisiblePortion()

std::wstring ChatPrompt::getVisiblePortion ( ) const

References getLineRef(), m_cols, m_prompt, and m_view.

Referenced by GUIChatConsole::drawPrompt().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ historyNext()

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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ historyPrev()

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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ input() [1/2]

void ChatPrompt::input ( const std::wstring & str)

References clampView(), m_cursor, m_nick_completion_end, m_nick_completion_start, and makeLineRef().

+ Here is the call graph for this function:

◆ input() [2/2]

void ChatPrompt::input ( wchar_t ch)

References clampView(), m_cursor, m_nick_completion_end, m_nick_completion_start, and makeLineRef().

Referenced by GUIChatConsole::OnEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ makeLineRef()

std::wstring & ChatPrompt::makeLineRef ( )
protected

References m_history, m_history_index, and m_line.

Referenced by clear(), cursorOperation(), input(), input(), nickCompletion(), and replace().

+ Here is the caller graph for this function:

◆ nickCompletion()

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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reformat()

void ChatPrompt::reformat ( u32 cols)

References clampView(), getLineRef(), m_cols, m_cursor, m_prompt, and m_view.

Referenced by ChatBackend::reformat().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ replace()

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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_cols

s32 ChatPrompt::m_cols = 0
private

◆ m_cursor

◆ m_cursor_len

s32 ChatPrompt::m_cursor_len = 0
private

◆ m_history

std::vector<HistoryEntry> ChatPrompt::m_history
private

◆ m_history_index

u32 ChatPrompt::m_history_index = 0
private

◆ m_history_limit

u32 ChatPrompt::m_history_limit
private

Referenced by addToHistory().

◆ m_line

std::wstring ChatPrompt::m_line = L""
private

◆ m_nick_completion_end

s32 ChatPrompt::m_nick_completion_end = 0
private

◆ m_nick_completion_start

s32 ChatPrompt::m_nick_completion_start = 0
private

◆ m_prompt

std::wstring ChatPrompt::m_prompt = L""
private

◆ m_view


The documentation for this class was generated from the following files: