mirror of
https://github.com/EnumeratedDev/Typer.git
synced 2025-07-01 07:48:20 +00:00
Add config options for showing and hiding the top menu and line index
This commit is contained in:
parent
444c355117
commit
dd0cc2a293
@ -3,4 +3,6 @@ selected_style: "default" # Style for 256-color and true-color capable terminals
|
||||
selected_style_fallback: "default-fallback" # Style for 8-color capable terminals (Like TTYs)
|
||||
|
||||
# Other
|
||||
show_top_menu: true
|
||||
show_line_index: true
|
||||
tab_indentation: 4 # Length of tab characters
|
@ -10,6 +10,8 @@ import (
|
||||
type TyperConfig struct {
|
||||
SelectedStyle string `yaml:"selected_style,omitempty"`
|
||||
FallbackStyle string `yaml:"fallback_style,omitempty"`
|
||||
ShowTopMenu bool `yaml:"show_top_menu,omitempty"`
|
||||
ShowLineIndex bool `yaml:"show_line_index,omitempty"`
|
||||
TabIndentation int `yaml:"tab_indentation,omitempty"`
|
||||
}
|
||||
|
||||
@ -19,6 +21,8 @@ func readConfig() {
|
||||
Config = TyperConfig{
|
||||
SelectedStyle: "default",
|
||||
FallbackStyle: "default-fallback",
|
||||
ShowTopMenu: true,
|
||||
ShowLineIndex: true,
|
||||
TabIndentation: 4,
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ func drawDropdowns(window *Window) {
|
||||
dropdownStyle := tcell.StyleDefault.Background(CurrentStyle.DropdownBg).Foreground(CurrentStyle.DropdownFg)
|
||||
for _, d := range dropdowns {
|
||||
drawBox(window.screen, d.PosX, d.PosY, d.PosX+d.Width+1, d.PosY+len(d.Options)+1, dropdownStyle)
|
||||
line := d.PosY
|
||||
line := 1
|
||||
for i, option := range d.Options {
|
||||
if d.Selected == i {
|
||||
drawText(window.screen, d.PosX+1, d.PosY+line, d.PosX+d.Width+1, d.PosY+line, dropdownStyle.Background(CurrentStyle.DropdownSel), option)
|
||||
|
@ -22,7 +22,13 @@ func initTopMenu() {
|
||||
Name: "File",
|
||||
Action: func(window *Window) {
|
||||
ClearDropdowns()
|
||||
d := CreateDropdownMenu([]string{"New", "Save", "Open", "Close", "Quit"}, 0, 1, 0, func(i int) {
|
||||
|
||||
y := 0
|
||||
if window.ShowTopMenu {
|
||||
y++
|
||||
}
|
||||
|
||||
d := CreateDropdownMenu([]string{"New", "Save", "Open", "Close", "Quit"}, 0, y, 0, func(i int) {
|
||||
switch i {
|
||||
case 0:
|
||||
RunCommand(window, "new-buffer")
|
||||
@ -45,7 +51,13 @@ func initTopMenu() {
|
||||
Name: "Edit",
|
||||
Action: func(window *Window) {
|
||||
ClearDropdowns()
|
||||
d := CreateDropdownMenu([]string{"Copy", "Paste"}, 0, 1, 0, func(i int) {
|
||||
|
||||
y := 0
|
||||
if window.ShowTopMenu {
|
||||
y++
|
||||
}
|
||||
|
||||
d := CreateDropdownMenu([]string{"Copy", "Paste"}, 0, y, 0, func(i int) {
|
||||
switch i {
|
||||
case 0:
|
||||
RunCommand(window, "copy")
|
||||
@ -63,6 +75,12 @@ func initTopMenu() {
|
||||
Name: "Buffers",
|
||||
Action: func(window *Window) {
|
||||
ClearDropdowns()
|
||||
|
||||
y := 0
|
||||
if window.ShowTopMenu {
|
||||
y++
|
||||
}
|
||||
|
||||
buffersSlice := make([]string, 0)
|
||||
for _, buffer := range Buffers {
|
||||
if window.CurrentBuffer == buffer {
|
||||
@ -74,7 +92,7 @@ func initTopMenu() {
|
||||
|
||||
slices.Sort(buffersSlice)
|
||||
|
||||
d := CreateDropdownMenu(buffersSlice, 0, 1, 0, func(i int) {
|
||||
d := CreateDropdownMenu(buffersSlice, 0, y, 0, func(i int) {
|
||||
start := strings.Index(buffersSlice[i], "[")
|
||||
end := strings.Index(buffersSlice[i], "]")
|
||||
|
||||
|
@ -39,8 +39,8 @@ var mouseHeld = false
|
||||
|
||||
func CreateWindow() (*Window, error) {
|
||||
window := Window{
|
||||
ShowTopMenu: true,
|
||||
ShowLineIndex: true,
|
||||
ShowTopMenu: Config.ShowTopMenu,
|
||||
ShowLineIndex: Config.ShowLineIndex,
|
||||
CursorMode: CursorModeBuffer,
|
||||
|
||||
CurrentBuffer: nil,
|
||||
|
Loading…
x
Reference in New Issue
Block a user