wex v24.04.0
Public Types | Public Member Functions | List of all members
wex::vi_mode Class Reference

Offers vi mode. More...

#include <wex/vi/mode.h>

Public Types

enum class  state_t {
  COMMAND , INSERT , INSERT_BLOCK , VISUAL ,
  VISUAL_BLOCK , VISUAL_LINE
}
 The possible vi mode states. More...
 

Public Member Functions

 vi_mode (vi *vi, const std::function< void(const std::string &command)> &insert=nullptr, const std::function< void()> &f=nullptr)
 Constructor,.
 
 ~vi_mode ()
 Destructor.
 
void command ()
 Transitions to command mode.
 
bool escape ()
 Escapes current mode.
 
state_t get () const
 Returns the state we are in.
 
bool is_command () const
 Returns true if in command mode.
 
bool is_insert () const
 Returns true if in insert mode.
 
bool is_visual () const
 Returns true if in visual mode.
 
const auto & insert_commands () const
 Returns insert commands.
 
const std::string str () const
 Returns mode as a string.
 
bool transition (std::string &command)
 Transitions to other mode depending on command.
 
void visual ()
 Transitions to visual mode.
 

Detailed Description

Offers vi mode.

dot_inline_dotgraph_4.png

Member Enumeration Documentation

◆ state_t

enum class wex::vi_mode::state_t
strong

The possible vi mode states.

Enumerator
COMMAND 

command (or navigation) mode

INSERT 

pressing key inserts key

INSERT_BLOCK 

as insert, while in visual rect mode

VISUAL 

navigation keys extend selection

VISUAL_BLOCK 

navigation keys extend rectangular selection

VISUAL_LINE 

complete lines are selected

Constructor & Destructor Documentation

◆ vi_mode()

wex::vi_mode::vi_mode ( vi * vi,
const std::function< void(const std::string &command)> & insert = nullptr,
const std::function< void()> & f = nullptr )

Constructor,.

Parameters
vispecify vi component
insertmethod to be called when going into insert mode
fmethod to be called when going back to command mode

Member Function Documentation

◆ transition()

bool wex::vi_mode::transition ( std::string & command)

Transitions to other mode depending on command.

Returns true if command represents a mode change, otherwise false. If true is returned, it does not mean that mode was changed, in case of readonly doc.