TSDuck v3.40-3963
MPEG Transport Stream Toolkit
Loading...
Searching...
No Matches
ts::EditLine Class Reference

Read input lines with bash-like line editing when possible. More...

#include <tsEditLine.h>

Public Member Functions

 EditLine (const UString &prompt=DefaultPrompt(), const UString &next_prompt=DefaultNextPrompt(), const UString &history_file=DefaultHistoryFile(), size_t history_size=DefaultHistorySize())
 Constructor.
 
 ~EditLine ()
 Destructor.
 
bool readLine (UString &line, bool skip_empty=true, bool trim=true, bool continuing=true)
 Read one line of input.
 

Static Public Member Functions

static UString DefaultHistoryFile ()
 Get the default history file name.
 
static size_t DefaultHistorySize ()
 Get the default maximum number of history lines to save.
 
static UString DefaultNextPrompt ()
 Get the default command line prompt for continuation lines (after a backslash).
 
static UString DefaultPrompt ()
 Get the default command line prompt.
 
static void SetDefaultHistoryFile (const UString &history_file)
 Set the default history file name.
 
static void SetDefaultHistorySize (size_t history_size)
 Set the default maximum number of history lines to save.
 
static void setDefaultNextPrompt (const UString &prompt)
 Set the default command line prompt for continuation lines (after a backslash).
 
static void setDefaultPrompt (const UString &prompt)
 Set the default command line prompt.
 

Detailed Description

Read input lines with bash-like line editing when possible.

Constructor & Destructor Documentation

◆ EditLine()

ts::EditLine::EditLine ( const UString prompt = DefaultPrompt(),
const UString next_prompt = DefaultNextPrompt(),
const UString history_file = DefaultHistoryFile(),
size_t  history_size = DefaultHistorySize() 
)

Constructor.

Parameters
[in]promptCommand line prompt.
[in]next_promptCommand line prompt.
[in]history_fileFile to load/save the history. The history is loaded in the constructor and saved in the destructor. If empty, no history is loaded.
[in]history_sizeMaximum number of history lines to save.

Member Function Documentation

◆ DefaultHistoryFile()

static UString ts::EditLine::DefaultHistoryFile ( )
inlinestatic

Get the default history file name.

The default initial file location depends on the operating system:

  • Windows: %APPDATA%\tsduck\.tshistory
  • Unix: $HOME/.tshistory
    Returns
    The default history file name.

◆ SetDefaultHistoryFile()

static void ts::EditLine::SetDefaultHistoryFile ( const UString history_file)
inlinestatic

Set the default history file name.

Parameters
[in]history_fileThe default history file name.

◆ DefaultHistorySize()

static size_t ts::EditLine::DefaultHistorySize ( )
inlinestatic

Get the default maximum number of history lines to save.

The initial default is 100 lines.

Returns
The default maximum number of history lines to save.

◆ SetDefaultHistorySize()

static void ts::EditLine::SetDefaultHistorySize ( size_t  history_size)
inlinestatic

Set the default maximum number of history lines to save.

Parameters
[in]history_sizeThe default maximum number of history lines to save.

◆ DefaultPrompt()

static UString ts::EditLine::DefaultPrompt ( )
inlinestatic

Get the default command line prompt.

The initial default is "> ".

Returns
The default command line prompt.

◆ setDefaultPrompt()

static void ts::EditLine::setDefaultPrompt ( const UString prompt)
inlinestatic

Set the default command line prompt.

Parameters
[in]promptCommand line prompt.

◆ DefaultNextPrompt()

static UString ts::EditLine::DefaultNextPrompt ( )
inlinestatic

Get the default command line prompt for continuation lines (after a backslash).

The initial default is ">>> ".

Returns
The default command line prompt for continuation lines.

◆ setDefaultNextPrompt()

static void ts::EditLine::setDefaultNextPrompt ( const UString prompt)
inlinestatic

Set the default command line prompt for continuation lines (after a backslash).

Parameters
[in]promptCommand line prompt for continuation lines.

◆ readLine()

bool ts::EditLine::readLine ( UString line,
bool  skip_empty = true,
bool  trim = true,
bool  continuing = true 
)

Read one line of input.

Parameters
[out]lineReturned line.
[in]skip_emptySkip empty lines, continue reading until a non-empty line is read.
[in]trimTrim leading and trailing spaces.
[in]continuingContinue reading lines when the end of line is a backslash and return a full rebuilt line.
Returns
True on success, false on error (typically end of input).

The documentation for this class was generated from the following file: