wex  v21.04.0
Public Member Functions | List of all members
wex::address Class Reference

Offers an address class to be used by vi address ranges. More...

#include <wex/address.h>

Public Member Functions

 address (ex *ex, int line)
 Constructor for an address from a line. More...
 
 address (ex *ex, const std::string &address=std::string())
 Constructor for an address. More...
 
bool adjust_window (const std::string &text) const
 Prints this address, with context.
 
bool append (const std::string &text) const
 Appends text to this address.
 
bool flags_supported (const std::string &flags) const
 Returns false if flags are unsupported.
 
int get_line () const
 If the line number was set using set_line, it returns this line number, otherwise converts the address to a line number. More...
 
bool insert (const std::string &text) const
 Inserts text at this address.
 
bool marker_add (char marker) const
 Marks this address.
 
bool marker_delete () const
 Deletes marker (if this address concerns a marker).
 
bool parse (const std::string &command, const std::string &text=std::string()) const
 Parse this address based on command, and text. More...
 
bool put (char name='0') const
 Append text from the specified register at this address, default uses yank register.
 
bool read (const std::string &arg) const
 Read file at this address.
 
const std::string regex_commands () const
 Supported 1addr commands.
 
bool write_line_number () const
 Shows this address in the ex bar.
 

Detailed Description

Offers an address class to be used by vi address ranges.

Constructor & Destructor Documentation

◆ address() [1/2]

wex::address::address ( ex ex,
int  line 
)

Constructor for an address from a line.

Parameters
exthe ex (or vi) component
linethe address

◆ address() [2/2]

wex::address::address ( ex ex,
const std::string &  address = std::string() 
)

Constructor for an address.

Parameters
exthe ex (or vi) component
addressthe address, being a string containing:
  • a normal line number
  • a defined marker, like 'x, or '<: begin of selection and '>: end of selection
  • $ : last line
  • . : current line
  • or a combination of these, using + or -
  • or empty, call set_line afterwards

Member Function Documentation

◆ get_line()

int wex::address::get_line ( ) const

If the line number was set using set_line, it returns this line number, otherwise converts the address to a line number.

This is the vi line number, so subtract 1 for stc line number. Returns 0 on error in address.

◆ parse()

bool wex::address::parse ( const std::string &  command,
const std::string &  text = std::string() 
) const

Parse this address based on command, and text.

Returns true if command is valid.

Parameters
commandmostly a one letter string like "z" for adjust_window
texttext, as required by command