Page MenuHomePhorge
Diviner Arcanist Tech Docs PhutilInteractiveEditor

final class PhutilInteractiveEditor
Arcanist Technical Documentation ()

Edit a document interactively, by launching $EDITOR (like vi or nano).

$result = id(new InteractiveEditor($document))
  ->setName('shopping_list')
  ->setLineOffset(15)
  ->editInteractively();

This will launch the user's $EDITOR to edit the specified '$document', and return their changes into '$result'.

Tasks

Creating a New Editor

  • public function __construct($content) — Constructs an interactive editor, using the text of a document.

Editing Interactively

  • public function editInteractively() — Launch an editor and edit the content. The edited content will be returned.

Configuring Options

  • public function setLineOffset($offset) — Set the line offset where the cursor should be positioned when the editor opens. By default, the cursor will be positioned at the start of the content.
  • public function getLineOffset() — Get the current line offset. See setLineOffset().
  • public function setName($name) — Set the document name. Depending on the editor, this may be exposed to the user and can give them a sense of what they're editing.
  • public function getName() — Get the current document name. See @{method:setName} for details.
  • public function setContent($content) — Set the text content to be edited.
  • public function getContent() — Retrieve the current content.
  • public function setFallbackEditor($editor) — Set the fallback editor program to be used if the env variable $EDITOR is not available and there is no `editor` binary in PATH.
  • public function setPreferredEditor($editor) — Set the preferred editor program. If set, this will override all other sources of editor configuration, like $EDITOR.
  • public function setTaskMessage($task_message) — Set the message that identifies the task for which the editor is being launched, displayed to the user prior to it being launched.
  • public function getTaskMessage() — Retrieve the current message that will display to the user just prior to invoking the editor.
  • public function getEditor() — Get the name of the editor program to use. The value of the environmental variable $EDITOR will be used if available; otherwise, the `editor` binary if present; otherwise the best editor will be selected.

Other Methods

Methods

public function __get($name)
Inherited

This method is not documented.
Parameters
$name
Return
wild

public function __set($name, $value)
Inherited

This method is not documented.
Parameters
$name
$value
Return
wild

public function current()
Inherited

This method is not documented.
Return
wild

public function key()
Inherited

This method is not documented.
Return
wild

public function next()
Inherited

This method is not documented.
Return
wild

public function rewind()
Inherited

This method is not documented.
Return
wild

public function valid()
Inherited

This method is not documented.
Return
wild

private function throwOnAttemptedIteration()
Inherited

This method is not documented.
Return
wild

public function getPhobjectClassConstant($key, $byte_limit)
Inherited

Phobject

Read the value of a class constant.

This is the same as just typing self::CONSTANTNAME, but throws a more useful message if the constant is not defined and allows the constant to be limited to a maximum length.

Parameters
string$keyName of the constant.
int|null$byte_limitMaximum number of bytes permitted in the value.
Return
stringValue of the constant.

public function __construct($content)

Constructs an interactive editor, using the text of a document.

Parameters
string$contentDocument text.
Return
this//Implicit.//

public function editInteractively()

Launch an editor and edit the content. The edited content will be returned.

Return
stringEdited content.

private function invokeEditor($editor, $path, $offset)

This method is not documented.
Parameters
$editor
$path
$offset
Return
wild

public function setLineOffset($offset)

Set the line offset where the cursor should be positioned when the editor opens. By default, the cursor will be positioned at the start of the content.

Parameters
int$offsetLine number where the cursor should be positioned.
Return
$this

public function getLineOffset()

Get the current line offset. See setLineOffset().

Return
intCurrent line offset.

public function setName($name)

Set the document name. Depending on the editor, this may be exposed to the user and can give them a sense of what they're editing.

Parameters
string$nameDocument name.
Return
$this

public function getName()

Get the current document name. See setName() for details.

Return
stringCurrent document name.

public function setContent($content)

Set the text content to be edited.

Parameters
string$contentNew content.
Return
$this

public function getContent()

Retrieve the current content.

Return
string

public function setFallbackEditor($editor)

Set the fallback editor program to be used if the env variable $EDITOR is not available and there is no editor binary in PATH.

Parameters
string$editorCommand-line editing program (e.g. 'emacs', 'vi')
Return
$this

public function setPreferredEditor($editor)

Set the preferred editor program. If set, this will override all other sources of editor configuration, like $EDITOR.

Parameters
string$editorCommand-line editing program (e.g. 'emacs', 'vi')
Return
$this

public function setTaskMessage($task_message)

Set the message that identifies the task for which the editor is being launched, displayed to the user prior to it being launched.

Parameters
string$task_messageThe message to display to the user.
Return
$this

public function getTaskMessage()

Retrieve the current message that will display to the user just prior to invoking the editor.

Return
stringThe message that will display to the user, or null if no message will be displayed.

public function getEditor()

Get the name of the editor program to use. The value of the environmental variable $EDITOR will be used if available; otherwise, the editor binary if present; otherwise the best editor will be selected.

Return
stringCommand-line editing program.