Minetest  5.4.0
ChatBuffer Class Reference

#include <chat.h>

+ Collaboration diagram for ChatBuffer:

Public Member Functions

 ChatBuffer (u32 scrollback)
 
 ~ChatBuffer ()=default
 
void addLine (const std::wstring &name, const std::wstring &text)
 
void clear ()
 
u32 getLineCount () const
 
const ChatLinegetLine (u32 index) const
 
void step (f32 dtime)
 
void deleteOldest (u32 count)
 
void deleteByAge (f32 maxAge)
 
u32 getRows () const
 
void reformat (u32 cols, u32 rows)
 
const ChatFormattedLinegetFormattedLine (u32 row) const
 
void scroll (s32 rows)
 
void scrollAbsolute (s32 scroll)
 
void scrollBottom ()
 
void scrollTop ()
 
u32 formatChatLine (const ChatLine &line, u32 cols, std::vector< ChatFormattedLine > &destination) const
 
void resize (u32 scrollback)
 

Protected Member Functions

s32 getTopScrollPos () const
 
s32 getBottomScrollPos () const
 

Private Attributes

u32 m_scrollback
 
std::vector< ChatLinem_unformatted
 
u32 m_cols = 0
 
u32 m_rows = 0
 
s32 m_scroll = 0
 
std::vector< ChatFormattedLinem_formatted
 
ChatFormattedLine m_empty_formatted_line
 

Constructor & Destructor Documentation

◆ ChatBuffer()

ChatBuffer::ChatBuffer ( u32  scrollback)

◆ ~ChatBuffer()

ChatBuffer::~ChatBuffer ( )
default

Member Function Documentation

◆ addLine()

void ChatBuffer::addLine ( const std::wstring &  name,
const std::wstring &  text 
)

References deleteOldest(), formatChatLine(), getBottomScrollPos(), m_cols, m_formatted, m_rows, m_scroll, m_scrollback, and m_unformatted.

Referenced by ChatBackend::addMessage().

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

◆ clear()

void ChatBuffer::clear ( )

References m_formatted, m_scroll, and m_unformatted.

Referenced by ChatBackend::clearRecentChat().

+ Here is the caller graph for this function:

◆ deleteByAge()

void ChatBuffer::deleteByAge ( f32  maxAge)

References deleteOldest(), and m_unformatted.

Referenced by ChatBackend::step().

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

◆ deleteOldest()

void ChatBuffer::deleteOldest ( u32  count)

References getBottomScrollPos(), m_formatted, m_scroll, m_unformatted, sanity_check, and scrollAbsolute().

Referenced by addLine(), deleteByAge(), and resize().

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

◆ formatChatLine()

u32 ChatBuffer::formatChatLine ( const ChatLine line,
u32  cols,
std::vector< ChatFormattedLine > &  destination 
) const

References EnrichedString::c_str(), ChatFormattedFragment::column, EnrichedString::empty(), ChatFormattedLine::first, ChatFormattedLine::fragments, EnrichedString::getString(), ChatLine::name, EnrichedString::size(), EnrichedString::substr(), ChatLine::text, and ChatFormattedFragment::text.

Referenced by addLine(), and reformat().

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

◆ getBottomScrollPos()

s32 ChatBuffer::getBottomScrollPos ( ) const
protected

References m_formatted, and m_rows.

Referenced by addLine(), deleteOldest(), reformat(), scrollAbsolute(), and scrollBottom().

+ Here is the caller graph for this function:

◆ getFormattedLine()

const ChatFormattedLine & ChatBuffer::getFormattedLine ( u32  row) const

References m_empty_formatted_line, m_formatted, and m_scroll.

Referenced by GUIChatConsole::drawText().

+ Here is the caller graph for this function:

◆ getLine()

const ChatLine & ChatBuffer::getLine ( u32  index) const

References getLineCount(), and m_unformatted.

Referenced by ChatBackend::getRecentChat().

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

◆ getLineCount()

u32 ChatBuffer::getLineCount ( ) const

References m_unformatted.

Referenced by getLine(), ChatBackend::getRecentChat(), and Game::updateChat().

+ Here is the caller graph for this function:

◆ getRows()

u32 ChatBuffer::getRows ( ) const

References m_rows.

Referenced by GUIChatConsole::drawPrompt(), GUIChatConsole::drawText(), ChatBackend::scrollPageDown(), and ChatBackend::scrollPageUp().

+ Here is the caller graph for this function:

◆ getTopScrollPos()

s32 ChatBuffer::getTopScrollPos ( ) const
protected

References m_formatted, and m_rows.

Referenced by scrollAbsolute(), and scrollTop().

+ Here is the caller graph for this function:

◆ reformat()

void ChatBuffer::reformat ( u32  cols,
u32  rows 
)

References formatChatLine(), getBottomScrollPos(), m_cols, m_formatted, m_rows, m_scroll, m_unformatted, scrollAbsolute(), and scrollBottom().

Referenced by ChatBackend::reformat().

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

◆ resize()

void ChatBuffer::resize ( u32  scrollback)

References deleteOldest(), m_scrollback, and m_unformatted.

Referenced by ChatBackend::applySettings().

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

◆ scroll()

void ChatBuffer::scroll ( s32  rows)

References m_scroll, and scrollAbsolute().

Referenced by ChatBackend::scroll(), scrollAbsolute(), ChatBackend::scrollPageDown(), and ChatBackend::scrollPageUp().

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

◆ scrollAbsolute()

void ChatBuffer::scrollAbsolute ( s32  scroll)

References getBottomScrollPos(), getTopScrollPos(), m_scroll, and scroll().

Referenced by deleteOldest(), reformat(), and scroll().

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

◆ scrollBottom()

void ChatBuffer::scrollBottom ( )

References getBottomScrollPos(), and m_scroll.

Referenced by reformat().

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

◆ scrollTop()

void ChatBuffer::scrollTop ( )

References getTopScrollPos(), and m_scroll.

+ Here is the call graph for this function:

◆ step()

void ChatBuffer::step ( f32  dtime)

References m_unformatted.

Referenced by ChatBackend::step().

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_cols

u32 ChatBuffer::m_cols = 0
private

Referenced by addLine(), and reformat().

◆ m_empty_formatted_line

ChatFormattedLine ChatBuffer::m_empty_formatted_line
private

Referenced by ChatBuffer(), and getFormattedLine().

◆ m_formatted

std::vector<ChatFormattedLine> ChatBuffer::m_formatted
private

◆ m_rows

u32 ChatBuffer::m_rows = 0
private

◆ m_scroll

s32 ChatBuffer::m_scroll = 0
private

◆ m_scrollback

u32 ChatBuffer::m_scrollback
private

Referenced by ChatBuffer(), addLine(), and resize().

◆ m_unformatted

std::vector<ChatLine> ChatBuffer::m_unformatted
private

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