Minetest  5.4.0
ChatPrompt Class Reference

#include <chat.h>

+ Collaboration diagram for ChatPrompt:

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::list< 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

void clampView ()
 

Private Attributes

std::wstring m_prompt = L""
 
std::wstring m_line = L""
 
std::vector< std::wstring > 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
 

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 m_history, m_history_index, and m_history_limit.

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

+ Here is the caller graph for this function:

◆ clampView()

void ChatPrompt::clampView ( )
protected

References m_cols, m_cursor, m_line, m_view, MYMAX, and MYMIN.

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

+ Here is the caller graph for this function:

◆ clear()

void ChatPrompt::clear ( )

◆ 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(), m_cursor, m_cursor_len, m_line, m_nick_completion_end, m_nick_completion_start, 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 m_line.

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

+ Here is the caller graph for this function:

◆ getSelection()

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

References m_cursor, m_cursor_len, and m_line.

Referenced by GUIChatConsole::OnEvent().

+ 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 m_cols, m_line, m_prompt, and m_view.

Referenced by GUIChatConsole::drawPrompt().

+ Here is the caller graph for this function:

◆ historyNext()

void ChatPrompt::historyNext ( )

References m_history, m_history_index, and replace().

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 m_history, m_history_index, and replace().

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_line, m_nick_completion_end, and m_nick_completion_start.

+ Here is the call graph for this function:

◆ input() [2/2]

void ChatPrompt::input ( wchar_t  ch)

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

Referenced by GUIChatConsole::OnEvent().

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

◆ nickCompletion()

void ChatPrompt::nickCompletion ( const std::list< std::string > &  names,
bool  backwards 
)

References clampView(), m_cursor, m_line, m_nick_completion_end, m_nick_completion_start, 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(), m_cols, m_cursor, m_line, 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(), m_cursor, m_line, m_nick_completion_end, m_nick_completion_start, and m_view.

Referenced by historyNext(), historyPrev(), 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<std::wstring> 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

s32 ChatPrompt::m_view = 0
private

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