FDOSTUI
FreeDOS Text User Interface
Public Member Functions | Protected Attributes | Private Member Functions | List of all members
edit Class Reference

Multi-line edit widget. More...

#include <edit.hpp>

Inheritance diagram for edit:
Inheritance graph
[legend]

Public Member Functions

 edit (int const i_pos_x, int const i_pos_y, unsigned int const i_len_x, unsigned int const i_len_y)
 constructor More...
 
virtual ~edit ()
 destructor More...
 
virtual void draw () const
 draws the widget More...
 
virtual enum event_response event_key (struct event_key const &i_event)
 handle key event More...
 
void focus_enter ()
 handle entering focus More...
 
void focus_leave ()
 handle leaving focus More...
 
unsigned char const __FAR * get_text ()
 get the text buffer More...
 
size_t get_text_length () const
 get the number of used bytes in the buffer More...
 
- Public Member Functions inherited from widget
 widget (int const i_pos_x, int const i_pos_y, unsigned int const i_len_x, unsigned int const i_len_y)
 constructor More...
 
virtual ~widget ()
 destructor More...
 
virtual void set_damage (unsigned int const i_damage=DAMAGE_NONE)
 set the damage bits More...
 
virtual bool close (bool const i_shutting_down)
 called when widget is about to be destroyed More...
 
bool contains (int const i_pos_x, int const i_pos_y) const
 test if point is contained within the widget More...
 
bool contains (struct box const &i_box) const
 test if rectangular region is contained within the widget More...
 
virtual enum event_response event_key_default (enum scancodes const i_scan)
 default key event handler More...
 
virtual enum event_response event_mouse (struct event_mouse const &i_event)
 handle mouse event More...
 
void get_box (struct box &o_box) const
 gets the rectangular region this widget occupies More...
 
bool get_can_focus () const
 gets whether or not the widget can receive focus More...
 
bool get_enabled () const
 gets whether or not the widget is enabled More...
 
bool get_has_focus () const
 gets whether or not the widget has focus More...
 
group *const get_parent () const
 gets the parent widget More...
 
void * get_user_data () const
 gets user defined data pointer More...
 
bool get_visible () const
 gets whether or not the widget is visible More...
 
int get_pos_x () const
 gets the relative x position of the widget More...
 
int get_pos_y () const
 gets the relative y position of the widget More...
 
unsigned int get_len_x () const
 gets the horizontal length of the widget More...
 
unsigned int get_len_y () const
 gets the vertical length of the widget More...
 
virtual void move (int const i_pos_x, int const i_pos_y)
 move the widget to a new position More...
 
virtual void resize (unsigned int const i_len_x, unsigned int const i_len_y)
 resize the widget More...
 
void set_can_close (bool const i_can_close)
 set internal indicator if widget can be closed More...
 
void set_disabled ()
 disable the widget More...
 
void set_enabled ()
 enable the widget
 
void set_hidden ()
 hide the widget More...
 
virtual void set_parent (group *const i_parent)
 sets the parent group of the widget More...
 
void set_user_data (void *io_user_data)
 sets the user defined data pointer More...
 
void set_visible ()
 sets the widget as visible More...
 
void translate_screen (int *const o_pos_x, int *const o_pos_y) const
 translate a widgets relative coordinates to screen coordinates More...
 

Protected Attributes

size_t m_caret_x
 
size_t m_caret_y
 
size_t m_sticky_caret_x
 
size_t m_cursor
 
size_t m_offset_x
 
size_t m_line_top
 
size_t m_line_top_offset
 
size_t m_lines
 
struct gapbuf m_gap
 
- Protected Attributes inherited from widget
unsigned int m_damage
 
unsigned int m_flags
 
struct box m_box
 
groupm_parent
 
void * m_user_data
 

Private Member Functions

 edit (const edit &)
 
editoperator= (edit const &)
 
void caret_set_position () const
 moves the cursor to the current position (m_caret) More...
 
bool char_backspace ()
 backspace More...
 
bool char_delete ()
 delete character More...
 
bool char_insert (unsigned char const i_char, enum cursor_mode const i_cursor_mode)
 insert character More...
 
bool char_insert_newline ()
 insert new line character More...
 
bool cursor_down ()
 move cursor down a line More...
 
bool cursor_end ()
 move cursor to end of line More...
 
bool cursor_home ()
 move cursor to end of line More...
 
bool cursor_left ()
 move cursor left More...
 
bool cursor_right ()
 move cursor right More...
 
void cursor_show ()
 sets the cursor type/shape. Cursor shape depends on the state of the cursor (insert/overwrite) and widget itself. More...
 
bool cursor_up ()
 move cursor up a line More...
 
bool move_to_offset_x (unsigned char __FAR *&io_ptr, size_t &io_offset, int &io_pos_y) const
 move to m_offset_x cursor position More...
 

Additional Inherited Members

- Public Types inherited from widget
enum  damage {
  DAMAGE_NONE = 0, DAMAGE_ALL = (1<<0), DAMAGE_LABEL = (1<<1), DAMAGE_VALUE = (1<<2),
  DAMAGE_SCROLL = (1<<3), DAMAGE_MOVED = (1<<4), DAMAGE_RESERVED1 = (1<<5), DAMAGE_RESERVED2 = (1<<6),
  DAMAGE_RESERVED3 = (1<<7)
}
 bit mask indicating what needs to be redrawn More...
 
- Protected Types inherited from widget
enum  flags {
  VISIBLE = (1 << 0), ENABLED = (1 << 1), CAN_FOCUS = (1 << 2), HAS_FOCUS = (1 << 3),
  CAN_CLOSE = (1 << 4)
}
 

Detailed Description

Multi-line edit widget.

Constructor & Destructor Documentation

◆ edit()

edit::edit ( int const  i_pos_x,
int const  i_pos_y,
unsigned int const  i_len_x,
unsigned int const  i_len_y 
)

constructor

Parameters
[in]i_pos_xx position to place widget
[in]i_pos_yy position to place widget
[in]i_len_xx length of widget
[in]i_len_yy length of widget
Returns
none

◆ ~edit()

edit::~edit ( )
virtual

destructor

Returns
none

Member Function Documentation

◆ caret_set_position()

void edit::caret_set_position ( ) const
private

moves the cursor to the current position (m_caret)

Returns
none

This routine does not alter the shape or visibility

◆ char_backspace()

bool edit::char_backspace ( )
private

backspace

Returns
false does not require a redraw
true requires a redraw

◆ char_delete()

bool edit::char_delete ( )
private

delete character

Returns
false does not require a redraw
true requires a redraw

◆ char_insert()

bool edit::char_insert ( unsigned char const  i_char,
enum cursor_mode const  i_cursor_mode 
)
private

insert character

Parameters
[in]i_charcharacter to insert
[in]i_cursor_modemode to insert (overwrite, insert)
Returns
false does not require a redraw
true requires a redraw

◆ char_insert_newline()

bool edit::char_insert_newline ( )
private

insert new line character

Returns
false does not require a redraw
true requires a redraw

◆ cursor_down()

bool edit::cursor_down ( )
private

move cursor down a line

Returns
false does not require a redraw
true requires a redraw

◆ cursor_end()

bool edit::cursor_end ( )
private

move cursor to end of line

Returns
false does not require a redraw
true requires a redraw

◆ cursor_home()

bool edit::cursor_home ( )
private

move cursor to end of line

Returns
false does not require a redraw
true requires a redraw

◆ cursor_left()

bool edit::cursor_left ( )
private

move cursor left

Returns
false does not require a redraw
true requires a redraw

◆ cursor_right()

bool edit::cursor_right ( )
private

move cursor right

Returns
false does not require a redraw
true requires a redraw

◆ cursor_show()

void edit::cursor_show ( )
inlineprivate

sets the cursor type/shape. Cursor shape depends on the state of the cursor (insert/overwrite) and widget itself.

Returns
none

◆ cursor_up()

bool edit::cursor_up ( )
private

move cursor up a line

Returns
false does not require a redraw
true requires a redraw

◆ draw()

void edit::draw ( ) const
virtual

draws the widget

This method should not be called directly.

See also
widget::draw for details.

Implements widget.

◆ event_key()

enum event_response edit::event_key ( struct event_key const &  i_event)
virtual

handle key event

Parameters
[in]i_eventkey event to handle
Returns
response how event was handled

Reimplemented from widget.

◆ focus_enter()

void edit::focus_enter ( )
virtual

handle entering focus

Returns
none

Reimplemented from widget.

◆ focus_leave()

void edit::focus_leave ( )
virtual

handle leaving focus

Returns
none

Reimplemented from widget.

◆ get_text()

unsigned char const __FAR * edit::get_text ( )
inline

get the text buffer

Returns
0 buffer empty
!0 address of buffer

◆ get_text_length()

size_t edit::get_text_length ( ) const
inline

get the number of used bytes in the buffer

Returns
>=0 number of bytes used in buffer

◆ move_to_offset_x()

bool edit::move_to_offset_x ( unsigned char __FAR *&  io_ptr,
size_t &  io_offset,
int &  io_pos_y 
) const
private

move to m_offset_x cursor position

Parameters
[in,out]io_ptrbuffer address
[in,out]io_offsetcursor position
[in,out]io_pos_yy position
Returns
false move not valid
true move was valid

Member Data Documentation

◆ m_caret_x

edit::m_caret_x
protected

x location of caret

◆ m_caret_y

edit::m_caret_y
protected

y location of caret

◆ m_cursor

edit::m_cursor
protected

current position in buffer

◆ m_gap

edit::m_gap
protected

gap buffer

◆ m_line_top

edit::m_line_top
protected

visible top line (vertical scroll)

◆ m_line_top_offset

edit::m_line_top_offset
protected

cursor position of top line

◆ m_lines

edit::m_lines
protected

total number of lines

◆ m_offset_x

edit::m_offset_x
protected

horizontal scroll position/offset

◆ m_sticky_caret_x

edit::m_sticky_caret_x
protected

x location of longest x caret position. Used to position caret on up/down operations.


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