wex  v21.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  state_t {
  COMMAND , INSERT , INSERT_BLOCK , VISUAL ,
  VISUAL_LINE , VISUAL_BLOCK
}
 The possible vi mode states. More...
 

Public Member Functions

 vi_mode (vi *vi, std::function< void(const std::string &command)> insert=nullptr, std::function< void()> f=nullptr)
 Constructor,. More...
 
 ~vi_mode ()
 Destructor.
 
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. More...
 

Detailed Description

Offers vi mode.

Member Enumeration Documentation

◆ state_t

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_LINE 

complete lines are selected

VISUAL_BLOCK 

navigation keys extend rectangular selection

Constructor & Destructor Documentation

◆ vi_mode()

wex::vi_mode::vi_mode ( vi vi,
std::function< void(const std::string &command)>  insert = nullptr,
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.