wex v24.10.0
|
Uses a stream for ex mode processing. More...
#include <wex/ex/ex-stream.h>
Public Types | |
enum class | loc_t { BEFORE , AFTER } |
The place where text will be inserted. More... | |
Public Member Functions | |
ex_stream (wex::ex *ex) | |
Constructor, specify ex component. | |
~ex_stream () override | |
Destructor. | |
bool | copy (const addressrange &range, const address &dest) |
Copies range to destination. | |
bool | erase (const addressrange &range) |
Deletes the range. | |
bool | find_data (const data::find &f) |
Finds the data,. | |
size_t | get_context_lines () const |
Returns context lines. | |
bool | get_lines (const addressrange &range, const std::string &flags="") |
Builds a string with text from range, result present in text. | |
bool | get_next_line () |
Goes to the next line. | |
bool | get_previous_line () |
Goes to the previous line. | |
const std::string * | get_work () const |
Returns content of work file. | |
bool | insert_text (int line, const std::string &text, loc_t loc=loc_t::BEFORE) |
Inserts text at specified line. | |
bool | is_block_mode () const |
Returns true if we are in block mode. | |
bool | is_modified () const |
Returns true if stream is modified;. | |
bool | join (const addressrange &range) |
Joins all lines in the range. | |
bool | marker_add (char marker, int line) |
Sets marker. | |
bool | marker_delete (char marker) |
Deletes marker. | |
int | marker_line (char marker) const |
Returns line for marker. | |
bool | move (const addressrange &range, const address &dest) |
Moves range to destination. | |
void | stream (file &f, size_t default_line_size=100000) |
Sets the streams and default line size. | |
bool | substitute (const addressrange &range, const data::substitute &data) |
Substitutes within the range find by replace. | |
auto & | text () const |
Returns text value, as result of doing a get_lines. | |
bool | write () |
Writes working stream to file. | |
bool | write (const addressrange &range, const std::string &file, bool append=false) |
Writes range to file. | |
bool | yank (const addressrange &range, char name='0') |
Yanks range to register, default to yank register. | |
bool | find (const std::string &text, int find_flags=-1, bool find_next=true) override |
Pure virtual interface. | |
int | get_current_line () const override |
Returns current line no. | |
int | get_line_count () const override |
Returns number of lines. | |
int | get_line_count_request () override |
Request for number of lines. | |
void | goto_line (int no) override |
Goes to specified line. | |
Public Member Functions inherited from wex::factory::text_window | |
virtual | ~text_window ()=default |
Destructor. | |
Uses a stream for ex mode processing.
Line numbers are stc line numbers, so start at line 0. All modifications are done in the temp file, and copied to the work file upon changing. If you ask for a write, the work file is copied to the original file.
|
strong |
bool wex::ex_stream::copy | ( | const addressrange & | range, |
const address & | dest ) |
Copies range to destination.
Returns false if no stream, or range or dest is invalid.
|
overridevirtual |
Pure virtual interface.
Finds next or previous.
text | text to find |
find_flags | search flags to be used:
|
find_next | finds next or previous |
Implements wex::factory::text_window.
bool wex::ex_stream::get_lines | ( | const addressrange & | range, |
const std::string & | flags = "" ) |
Builds a string with text from range, result present in text.
Returns false if no stream, or range is invalid.
range | the range |
flags | flags to specify behaviour, see get_lines at ex/util.h |
bool wex::ex_stream::insert_text | ( | int | line, |
const std::string & | text, | ||
loc_t | loc = loc_t::BEFORE ) |
Inserts text at specified line.
Returns false if no stream, or address is invalid.
|
inline |
Returns true if we are in block mode.
Block mode implies that no eols were found when reading lines with max size.
bool wex::ex_stream::join | ( | const addressrange & | range | ) |
Joins all lines in the range.
Returns false if no stream, or range is invalid.
bool wex::ex_stream::marker_add | ( | char | marker, |
int | line ) |
Sets marker.
Returns false if marker is invalid.
int wex::ex_stream::marker_line | ( | char | marker | ) | const |
Returns line for marker.
Returns LINE_NUMBER_UNKNOWN if marker not known.
bool wex::ex_stream::move | ( | const addressrange & | range, |
const address & | dest ) |
Moves range to destination.
Returns false if no stream, or range or dest is invalid.
void wex::ex_stream::stream | ( | file & | f, |
size_t | default_line_size = 100000 ) |
Sets the streams and default line size.
Puts first line on stc. This must be called before the other methods.
bool wex::ex_stream::substitute | ( | const addressrange & | range, |
const data::substitute & | data ) |
Substitutes within the range find by replace.
Returns false if no stream, or range is invalid.
bool wex::ex_stream::write | ( | ) |
Writes working stream to file.
Returns false if internal streams are not valid.
bool wex::ex_stream::write | ( | const addressrange & | range, |
const std::string & | file, | ||
bool | append = false ) |
Writes range to file.
Returns false if no stream, or range is invalid.
bool wex::ex_stream::yank | ( | const addressrange & | range, |
char | name = '0' ) |
Yanks range to register, default to yank register.
Returns false if no stream, or range is invalid.