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

Uses a stream for ex mode processing. More...

#include <wex/ex/ex-stream.h>

Inheritance diagram for wex::ex_stream:
Inheritance graph
[legend]

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 (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.
 
const std::string * get_work () const
 Returns content of work file.
 
bool insert_text (const address &address, const std::string &text, loc_t loc=loc_t::BEFORE)
 Inserts text at specified address.
 
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.
 

Detailed Description

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.

Member Enumeration Documentation

◆ loc_t

enum class wex::ex_stream::loc_t
strong

The place where text will be inserted.

Enumerator
BEFORE 

before address

AFTER 

after address

Member Function Documentation

◆ copy()

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.

◆ find()

bool wex::ex_stream::find ( const std::string & text,
int find_flags = -1,
bool find_next = true )
overridevirtual

Pure virtual interface.

Finds next or previous.

Parameters
texttext to find
find_flagssearch flags to be used:
  • wxSTC_FIND_WHOLEWORD
  • wxSTC_FIND_MATCHCASE
  • wxSTC_FIND_WORDSTART
  • wxSTC_FIND_REGEXP
  • wxSTC_FIND_POSIX
  • if -1, use flags from find replace data
find_nextfinds next or previous

Implements wex::factory::text_window.

◆ get_lines()

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.

Parameters
rangethe range
flagsflags to specify behaviour, see get_lines at ex/util.h

◆ insert_text()

bool wex::ex_stream::insert_text ( const address & address,
const std::string & text,
loc_t loc = loc_t::BEFORE )

Inserts text at specified address.

Returns false if no stream, of address is invalid.

◆ is_block_mode()

bool wex::ex_stream::is_block_mode ( ) const
inline

Returns true if we are in block mode.

Block mode implies that no eols were found when reading lines with max size.

◆ join()

bool wex::ex_stream::join ( const addressrange & range)

Joins all lines in the range.

Returns false if no stream, or range is invalid.

◆ marker_add()

bool wex::ex_stream::marker_add ( char marker,
int line )

Sets marker.

Returns false if marker is invalid.

◆ marker_line()

int wex::ex_stream::marker_line ( char marker) const

Returns line for marker.

Returns LINE_NUMBER_UNKNOWN if marker not known.

◆ move()

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.

◆ stream()

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.

◆ substitute()

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.

◆ write() [1/2]

bool wex::ex_stream::write ( )

Writes working stream to file.

Returns false if internal streams are not valid.

◆ write() [2/2]

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.

◆ yank()

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.