Extracted readline from the dead prompt module
This commit is contained in:
@@ -12,7 +12,7 @@ use crate::{
|
||||
libsh::error::{ShErr, ShErrKind, ShResult, ShResultExt},
|
||||
parse::{NdRule, Node},
|
||||
procio::{borrow_fd, IoStack},
|
||||
prompt::readline::term::RawModeGuard,
|
||||
readline::term::RawModeGuard,
|
||||
state::{self, read_vars, write_vars, VarFlags},
|
||||
};
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ use crate::parse::execute::exec_input;
|
||||
use crate::parse::lex::{LexFlags, LexStream, Tk, TkFlags, TkRule, is_field_sep, is_hard_sep};
|
||||
use crate::parse::{Redir, RedirType};
|
||||
use crate::procio::{IoBuf, IoFrame, IoMode, IoStack};
|
||||
use crate::prompt::readline::markers;
|
||||
use crate::readline::markers;
|
||||
use crate::state::{
|
||||
LogTab, VarFlags, read_jobs, read_logic, read_vars, write_jobs, write_meta, write_vars
|
||||
};
|
||||
|
||||
@@ -11,7 +11,7 @@ pub mod libsh;
|
||||
pub mod parse;
|
||||
pub mod prelude;
|
||||
pub mod procio;
|
||||
pub mod prompt;
|
||||
pub mod readline;
|
||||
pub mod shopt;
|
||||
pub mod signal;
|
||||
pub mod state;
|
||||
@@ -31,9 +31,8 @@ use crate::libsh::error::{ShErr, ShErrKind, ShResult};
|
||||
use crate::libsh::sys::TTY_FILENO;
|
||||
use crate::parse::execute::exec_input;
|
||||
use crate::prelude::*;
|
||||
use crate::prompt::get_prompt;
|
||||
use crate::prompt::readline::term::{LineWriter, RawModeGuard, raw_mode};
|
||||
use crate::prompt::readline::{Prompt, ReadlineEvent, ShedVi};
|
||||
use crate::readline::term::{LineWriter, RawModeGuard, raw_mode};
|
||||
use crate::readline::{Prompt, ReadlineEvent, ShedVi};
|
||||
use crate::signal::{GOT_SIGWINCH, JOB_DONE, QUIT_CODE, check_signals, sig_setup, signals_pending};
|
||||
use crate::state::{read_logic, source_rc, write_jobs, write_meta};
|
||||
use clap::Parser;
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
pub mod readline;
|
||||
pub mod statusline;
|
||||
|
||||
use crate::{expand::expand_prompt, libsh::error::ShResult, prelude::*};
|
||||
|
||||
/// Initialize the line editor
|
||||
pub fn get_prompt() -> ShResult<String> {
|
||||
let Ok(prompt) = env::var("PS1") else {
|
||||
// default prompt expands to:
|
||||
//
|
||||
// username@hostname
|
||||
// short/path/to/pwd/
|
||||
// $ _
|
||||
let default = "\\e[0m\\n\\e[1;0m\\u\\e[1;36m@\\e[1;31m\\h\\n\\e[1;36m\\W\\e[1;32m/\\n\\e[1;32m\\$\\e[0m ";
|
||||
return expand_prompt(default);
|
||||
};
|
||||
let sanitized = format!("\\e[0m{prompt}");
|
||||
|
||||
expand_prompt(&sanitized)
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
|
||||
@@ -4,7 +4,7 @@ use crate::{
|
||||
builtin::BUILTINS,
|
||||
libsh::error::{ShErr, ShErrKind, ShResult},
|
||||
parse::lex::{self, LexFlags, Tk, TkFlags},
|
||||
prompt::readline::{
|
||||
readline::{
|
||||
Marker, annotate_input, annotate_input_recursive, get_insertions,
|
||||
markers::{self, is_marker},
|
||||
},
|
||||
@@ -6,7 +6,7 @@ use std::{
|
||||
|
||||
use crate::{
|
||||
libsh::term::{Style, StyleSet, Styled},
|
||||
prompt::readline::{annotate_input, markers::{self, is_marker}},
|
||||
readline::{annotate_input, markers::{self, is_marker}},
|
||||
state::{read_logic, read_meta, read_shopts},
|
||||
};
|
||||
|
||||
@@ -12,7 +12,7 @@ use std::{
|
||||
use crate::prelude::*;
|
||||
use crate::{
|
||||
libsh::error::{ShErr, ShErrKind, ShResult},
|
||||
prompt::readline::linebuf::LineBuf,
|
||||
readline::linebuf::LineBuf,
|
||||
};
|
||||
|
||||
use super::vicmd::Direction; // surprisingly useful
|
||||
@@ -14,7 +14,7 @@ use crate::{
|
||||
libsh::{
|
||||
error::ShResult,
|
||||
term::{Style, Styled},
|
||||
}, parse::lex::{LexFlags, LexStream, Tk, TkFlags, TkRule}, prelude::*, prompt::readline::{markers, register::{write_register, RegisterContent}}, state::read_shopts
|
||||
}, parse::lex::{LexFlags, LexStream, Tk, TkFlags, TkRule}, prelude::*, readline::{markers, register::{write_register, RegisterContent}}, state::read_shopts
|
||||
};
|
||||
|
||||
const PUNCTUATION: [&str; 3] = ["?", "!", "."];
|
||||
@@ -11,7 +11,7 @@ use crate::expand::expand_prompt;
|
||||
use crate::libsh::sys::TTY_FILENO;
|
||||
use crate::parse::lex::LexStream;
|
||||
use crate::prelude::*;
|
||||
use crate::prompt::readline::term::{Pos, calc_str_width};
|
||||
use crate::readline::term::{Pos, calc_str_width};
|
||||
use crate::state::read_shopts;
|
||||
use crate::{
|
||||
libsh::{
|
||||
@@ -19,7 +19,7 @@ use crate::{
|
||||
term::{Style, Styled},
|
||||
},
|
||||
parse::lex::{self, LexFlags, Tk, TkFlags, TkRule},
|
||||
prompt::readline::{complete::Completer, highlight::Highlighter},
|
||||
readline::{complete::Completer, highlight::Highlighter},
|
||||
};
|
||||
|
||||
pub mod complete;
|
||||
@@ -22,7 +22,7 @@ use crate::{
|
||||
error::{ShErr, ShErrKind, ShResult},
|
||||
sys::TTY_FILENO,
|
||||
},
|
||||
prompt::readline::keys::{KeyCode, ModKeys},
|
||||
readline::keys::{KeyCode, ModKeys},
|
||||
shopt::ShedBellStyle,
|
||||
state::read_shopts,
|
||||
};
|
||||
@@ -8,7 +8,7 @@ use crate::{
|
||||
builtin::{BUILTINS, trap::TrapTarget}, exec_input, jobs::JobTab, libsh::{
|
||||
error::{ShErr, ShErrKind, ShResult},
|
||||
utils::VecDequeExt,
|
||||
}, parse::{ConjunctNode, NdRule, Node, ParsedSrc}, prelude::*, prompt::readline::markers, shopt::ShOpts
|
||||
}, parse::{ConjunctNode, NdRule, Node, ParsedSrc}, prelude::*, readline::markers, shopt::ShOpts
|
||||
};
|
||||
|
||||
pub struct Shed {
|
||||
|
||||
Reference in New Issue
Block a user