Rudimentarily add colors
This commit is contained in:
parent
275e5c3f7d
commit
d52ef78a9b
3 changed files with 22 additions and 6 deletions
18
cli/cli.odin
18
cli/cli.odin
|
|
@ -14,9 +14,7 @@ import "core:sys/posix"
|
|||
import "core:path/filepath"
|
||||
import "core:unicode/utf8"
|
||||
|
||||
INPUT_MAX :: 4096
|
||||
HISTORY_MAX :: 2048
|
||||
HISTORY_FILE :: "skal.history"
|
||||
import "../config"
|
||||
|
||||
History :: struct {
|
||||
data: [dynamic][]rune,
|
||||
|
|
@ -50,7 +48,7 @@ init_cli :: proc () {
|
|||
home_path := string(posix.getenv("HOME"))
|
||||
log.assertf(home_path != "", "Home path not found")
|
||||
|
||||
term.history.file = filepath.join({home_path, HISTORY_FILE}, context.allocator)
|
||||
term.history.file = filepath.join({home_path, config.HISTORY_FILE}, context.allocator)
|
||||
log.assertf(mem_err == nil, "Memory allocation failed")
|
||||
|
||||
USER_PERMISSIONS :: 0o600
|
||||
|
|
@ -112,7 +110,17 @@ get_prompt_prefix :: proc() -> string {
|
|||
user = string(pw.pw_name)
|
||||
}
|
||||
|
||||
prompt_parts := []string {user, " :: ", dir, " » "}
|
||||
prompt_parts := []string {
|
||||
config.USER_COLOR,
|
||||
user,
|
||||
config.DETAILS_COLOR,
|
||||
" :: ",
|
||||
config.DIR_COLOR,
|
||||
dir,
|
||||
config.DETAILS_COLOR,
|
||||
" » ",
|
||||
config.BASE_COLOR}
|
||||
|
||||
prompt, err := strings.concatenate(prompt_parts[:], context.temp_allocator)
|
||||
log.assertf(err == nil, "Memory allocation failed")
|
||||
|
||||
|
|
|
|||
7
config/config.odin
Normal file
7
config/config.odin
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
package config
|
||||
|
||||
HISTORY_FILE :: "skal.history"
|
||||
USER_COLOR :: "\x1b[0m"
|
||||
DETAILS_COLOR :: "\x1b[34m"
|
||||
DIR_COLOR :: "\x1b[32m"
|
||||
BASE_COLOR :: "\x1b[0m"
|
||||
|
|
@ -10,6 +10,7 @@ import "core:log"
|
|||
|
||||
import "../parser"
|
||||
import "../cli"
|
||||
import "../config"
|
||||
|
||||
ShellState :: enum {
|
||||
Continue,
|
||||
|
|
@ -40,7 +41,7 @@ handle_backround_process :: proc"c"(sig: posix.Signal) {
|
|||
|
||||
if background_pid > 0 && background_pid != foreground_pid {
|
||||
fmt.printf("skal: [%d] done", background_pid)
|
||||
// Clear prompt
|
||||
// todo: skip and redraw prompt with input
|
||||
}
|
||||
|
||||
if foreground_pid == background_pid {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue