Added Italic and Bold to prompt, removed some newlines when autocomplete

This commit is contained in:
Justine Pelletreau 2023-02-24 11:59:36 +01:00
parent eda72c00ab
commit 0656f163fd
5 changed files with 26 additions and 4 deletions

7
Cargo.lock generated
View File

@ -195,6 +195,12 @@ version = "0.6.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848"
[[package]]
name = "shell-words"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde"
[[package]]
name = "sqish"
version = "1.0.0"
@ -203,6 +209,7 @@ dependencies = [
"dirs",
"gethostname",
"regex",
"shell-words",
"termion",
"unicode-segmentation",
"users",

View File

@ -18,8 +18,6 @@ TODO:
* Allow redirecting >> to the end of a file ?
* Allow && in commands ?
* Improve word jumping
* Allow bold / italic / etc in prompt
* Reduce newlines in autocompletes
## sqishrc (Config)
See the included sqishrc file included for comments, and copy it as ~/.sqishrc for use (optionnal).

View File

@ -24,6 +24,11 @@
#RGB !
#RGB is defined as $RGB|red|green|blue_
#For example $RGB|108|84|30_ gives you an ugly shade of brown
#
#Styles:
#BOLD : start of a bold block
#ITA : start of an italic block
#STYLERESET : reset all styles.
prompt: "$COLORLBLACK_ !$HISTNUMBER_$COLORCYAN_[$USER_@$HOSTNAME_]$RGB|125|0|125_$DIR_> $COLORRESET_"
#Classic aliases, can be used in conjunction with hotkeys

View File

@ -390,7 +390,7 @@ pub mod shell {
//Search
*&mut mycommand = replace_signs(&mycommand);
let (res, list) = Search::build(&mycommand).unwrap().autocomplete();
if list.len() > 0 { write!(stdout, "\r\n{}\r\n", list); }
if list.len() > 0 { write!(stdout, "{}", list); }
mycommand.clear();
mycommand.push_str(&res);
max_pos = res.len();

View File

@ -1,5 +1,5 @@
use users::{get_user_by_uid, get_current_uid};
use termion::color;
use termion::{color, style};
use std::{env, fs};
use std::collections::HashMap;
use regex::Regex;
@ -112,6 +112,7 @@ impl SqishConf {
fn handle_colors(&mut self) {
//Colors
let reset = format!("{}", color::Fg(color::Reset));
let green = format!("{}", color::Fg(color::Green));
let blue = format!("{}", color::Fg(color::Blue));
@ -121,6 +122,12 @@ impl SqishConf {
let cyan = format!("{}", color::Fg(color::Cyan));
let lightblack = format!("{}", color::Fg(color::LightBlack));
//Styles
let ita = format!("{}", style::Italic);
let bold = format!("{}", style::Bold);
let stylereset = format!("{}", style::Reset);
//Colors replace
let mut prompt = self.promptline.replace("$COLORGREEN_", &green);
prompt = prompt.replace("$COLORBLUE_", &blue);
prompt = prompt.replace("$COLORRED_", &red);
@ -129,6 +136,11 @@ impl SqishConf {
prompt = prompt.replace("$COLORCYAN_", &cyan);
prompt = prompt.replace("$COLORLBLACK_", &lightblack);
prompt = prompt.replace("$COLORRESET_", &reset);
//Styles replace
prompt = prompt.replace("$ITA_", &ita);
prompt = prompt.replace("$BOLD_", &bold);
prompt = prompt.replace("$STYLERESET_", &stylereset);
let promptown = prompt.to_owned();
self.promptline = promptown;
}