Public Member Functions | Data Fields | Private Member Functions

Textbuf Struct Reference

Helper/buffer for input fields. More...

#include <textbuf_type.h>

Public Member Functions

void Initialize (char *buf, uint16 max_bytes)
 Initialize the textbuffer by supplying it the buffer to write into and the maximum length of this buffer.
void Initialize (char *buf, uint16 max_bytes, uint16 max_chars)
 Initialize the textbuffer by supplying it the buffer to write into and the maximum length of this buffer.
void DeleteAll ()
 Delete every character in the textbuffer.
bool DeleteChar (int delmode)
 Delete a character from a textbuffer, either with 'Delete' or 'Backspace' The character is delete from the position the caret is at.
bool InsertChar (uint32 key)
bool InsertClipboard ()
 Insert a chunk of text from the clipboard onto the textbuffer.
bool MovePos (int navmode)
 Handle text navigation with arrow keys left/right.
bool HandleCaret ()
 Handle the flashing of the caret.
void UpdateSize ()
 Update Textbuf type with its actual physical character and screenlength Get the count of characters in the string as well as the width in pixels.

Data Fields

char * buf
 buffer in which text is saved
uint16 max_bytes
 the maximum size of the buffer in bytes (including terminating '')
uint16 max_chars
 the maximum size of the buffer in characters (including terminating '')
uint16 bytes
 the current size of the string in bytes (including terminating '')
uint16 chars
 the current size of the string in characters (including terminating '')
uint16 pixels
 the current size of the string in pixels
bool caret
 is the caret ("_") visible or not
uint16 caretpos
 the current position of the caret in the buffer, in bytes
uint16 caretxoffs
 the current position of the caret in pixels

Private Member Functions

void DelChar (bool backspace)

Detailed Description

Helper/buffer for input fields.

Definition at line 16 of file textbuf_type.h.


Member Function Documentation

bool Textbuf::DeleteChar ( int  delmode  ) 

Delete a character from a textbuffer, either with 'Delete' or 'Backspace' The character is delete from the position the caret is at.

Parameters:
delmode Type of deletion, either WKC_BACKSPACE or WKC_DELETE
Returns:
Return true on successful change of Textbuf, or false otherwise

Definition at line 61 of file textbuf.cpp.

References bytes.

Referenced by OskWindow::OnClick(), and IConsoleWindow::OnKeyPress().

bool Textbuf::HandleCaret (  ) 

Handle the flashing of the caret.

Returns:
True if the caret state changes.

Definition at line 263 of file textbuf.cpp.

References caret.

Referenced by IConsoleWindow::OnMouseLoop().

void Textbuf::Initialize ( char *  buf,
uint16  max_bytes,
uint16  max_chars 
)

Initialize the textbuffer by supplying it the buffer to write into and the maximum length of this buffer.

Parameters:
buf the buffer that will be holding the data for input
max_bytes maximum size in bytes, including terminating ''
max_chars maximum size in chars, including terminating ''

Definition at line 221 of file textbuf.cpp.

References caret, and UpdateSize().

void Textbuf::Initialize ( char *  buf,
uint16  max_bytes 
)

Initialize the textbuffer by supplying it the buffer to write into and the maximum length of this buffer.

Parameters:
buf the buffer that will be holding the data for input
max_bytes maximum size in bytes, including terminating ''

Definition at line 209 of file textbuf.cpp.

Referenced by AIDebugWindow::AIDebugWindow(), NetworkChatWindow::NetworkChatWindow(), and NetworkContentListWindow::NetworkContentListWindow().

bool Textbuf::InsertClipboard (  ) 

Insert a chunk of text from the clipboard onto the textbuffer.

Get TEXT clipboard and append this up to the maximum length (either absolute or screenlength). If maxlength is zero, we don't care about the screenlength but only about the physical length of the string

Returns:
true on successful change of Textbuf, or false otherwise

Definition at line 115 of file textbuf.cpp.

References buf, bytes, caretxoffs, chars, FS_NORMAL, GetCharacterWidth(), GetClipboardContents(), lengthof, max_bytes, max_chars, pixels, and Utf8CharLen().

Referenced by IConsoleWindow::OnKeyPress().

bool Textbuf::MovePos ( int  navmode  ) 

Handle text navigation with arrow keys left/right.

This defines where the caret will blink and the next characer interaction will occur

Parameters:
navmode Direction in which navigation occurs WKC_LEFT, WKC_RIGHT, WKC_END, WKC_HOME
Returns:
Return true on successful change of Textbuf, or false otherwise

Definition at line 160 of file textbuf.cpp.

References buf, bytes, caretxoffs, FS_NORMAL, GetCharacterWidth(), pixels, Utf8Decode(), and Utf8PrevChar().

Referenced by OskWindow::OnClick(), and IConsoleWindow::OnKeyPress().

void Textbuf::UpdateSize (  ) 

Update Textbuf type with its actual physical character and screenlength Get the count of characters in the string as well as the width in pixels.

Useful when copying in a larger amount of text at once

Definition at line 238 of file textbuf.cpp.

References buf, bytes, caretxoffs, chars, FS_NORMAL, GetCharacterWidth(), max_bytes, max_chars, pixels, and Utf8CharLen().

Referenced by AIDebugWindow::AIDebugWindow(), NetworkChatWindow::ChatTabCompletion(), SignListWindow::ClearFilterTextWidget(), IConsoleHistoryNavigate(), Initialize(), and OskWindow::OnClick().


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