[−][src]Trait shelp::LangInterface
LangInterface
is a trait used by Repl to provide dependent specific features.
Implement only the functions which you want, since there are default implementations for all of them.
Provided methods
pub fn print_line(stdout: &mut Stdout, line: &str) -> Result<()>
[src]
Given a line of text, this function should print the line. This should be overridden if you want to lint the output in the repl.
pub fn get_indent(lines: &[String]) -> usize
[src]
Given the lines up to the place a new line is being added, this function should give the indentation of the new line.
For example, take the following [rust] code:
if true { // <------------- PRESSED ENTER HERE }
Here the first two lines will be give: ['let a = 213;', 'if true {']
, and the expected
indent would be 4
such that the code would become:
if true { // CURSOR HERE }
This is also used to detect if a new line should be added, or whether the command should be returned for execution. Take the following example:
if true { // <------------- PRESSED ENTER HERE
The indentation here would be 4
since its the start of the new block. So a new line will
be added instead of returning all the lines for processing.
if true {
// CURSOR HERE