mirror of
https://github.com/EnumeratedDev/Typer.git
synced 2025-07-03 08:28:22 +00:00
Compare commits
No commits in common. "f30eb3c46f74cd09ec959ba9e8d9b310609f655d" and "2d49f84d6f2cc3bdeaa5b10f3a8837ddc5860727" have entirely different histories.
f30eb3c46f
...
2d49f84d6f
@ -5,6 +5,5 @@ selected_style_fallback: "default-fallback" # Style for 8-color capable terminal
|
||||
# Other
|
||||
show_top_menu: true
|
||||
show_line_index: true
|
||||
extend_line_index: false # Extend line index to the bottom of the screen
|
||||
buffer_info_message: "File: %f Cursor: (%x, %y, %p) Chars: %c"
|
||||
tab_indentation: 4 # Length of tab characters
|
@ -12,7 +12,6 @@ type TyperConfig struct {
|
||||
FallbackStyle string `yaml:"fallback_style,omitempty"`
|
||||
ShowTopMenu bool `yaml:"show_top_menu,omitempty"`
|
||||
ShowLineIndex bool `yaml:"show_line_index,omitempty"`
|
||||
ExtendLineIndex bool `yaml:"extend_line_index,omitempty"`
|
||||
BufferInfoMessage string `yaml:"buffer_info_message,omitempty"`
|
||||
TabIndentation int `yaml:"tab_indentation,omitempty"`
|
||||
}
|
||||
@ -25,7 +24,6 @@ func readConfig() {
|
||||
FallbackStyle: "default-fallback",
|
||||
ShowTopMenu: true,
|
||||
ShowLineIndex: true,
|
||||
ExtendLineIndex: false,
|
||||
BufferInfoMessage: "File: %f Cursor: (%x, %y, %p) Chars: %c",
|
||||
TabIndentation: 4,
|
||||
}
|
||||
|
@ -12,22 +12,16 @@ func drawLineIndex(window *Window) {
|
||||
|
||||
lineIndexStyle := tcell.StyleDefault.Background(CurrentStyle.LineIndexBg).Foreground(CurrentStyle.LineIndexFg)
|
||||
|
||||
_, sizeY := screen.Size()
|
||||
|
||||
y := 0
|
||||
if window.ShowTopMenu {
|
||||
y = 1
|
||||
}
|
||||
|
||||
lineIndexSize := getLineIndexSize(window)
|
||||
|
||||
_, bufferY1, _, bufferY2 := window.GetTextAreaDimensions()
|
||||
|
||||
lineIndex := 1 + buffer.OffsetY
|
||||
for y := bufferY1; y <= bufferY2; y++ {
|
||||
if lineIndex > strings.Count(buffer.Contents, "\n")+1 {
|
||||
if Config.ExtendLineIndex {
|
||||
for x := 0; x < lineIndexSize; x++ {
|
||||
screen.SetContent(x, y, ' ', nil, lineIndexStyle)
|
||||
}
|
||||
continue
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
for lineIndex := 1 + buffer.OffsetY; lineIndex <= strings.Count(buffer.Contents, "\n")+1 && lineIndex < sizeY+buffer.OffsetY; lineIndex++ {
|
||||
|
||||
for x := 0; x < lineIndexSize; x++ {
|
||||
screen.SetContent(x, y, ' ', nil, lineIndexStyle)
|
||||
@ -36,8 +30,7 @@ func drawLineIndex(window *Window) {
|
||||
text := strconv.Itoa(lineIndex)
|
||||
|
||||
drawText(screen, lineIndexSize-len(text)-1, y, lineIndexSize, y, lineIndexStyle, text)
|
||||
|
||||
lineIndex++
|
||||
y++
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,6 @@ func main() {
|
||||
|
||||
for window.screen != nil {
|
||||
window.Draw()
|
||||
window.ProcessEvents()
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -126,9 +126,7 @@ func (window *Window) Draw() {
|
||||
|
||||
// Update screen
|
||||
window.screen.Show()
|
||||
}
|
||||
|
||||
func (window *Window) ProcessEvents() {
|
||||
// Poll event
|
||||
ev := window.screen.PollEvent()
|
||||
|
||||
@ -138,13 +136,13 @@ func (window *Window) ProcessEvents() {
|
||||
window.screen.Sync()
|
||||
window.SyncBufferOffset()
|
||||
case *tcell.EventMouse:
|
||||
window.handleMouseInput(ev)
|
||||
window.mouseInput(ev)
|
||||
case *tcell.EventKey:
|
||||
window.handleKeyInput(ev)
|
||||
window.input(ev)
|
||||
}
|
||||
}
|
||||
|
||||
func (window *Window) handleKeyInput(ev *tcell.EventKey) {
|
||||
func (window *Window) input(ev *tcell.EventKey) {
|
||||
if ev.Key() == tcell.KeyRight { // Navigation Keys
|
||||
if window.CursorMode == CursorModeBuffer {
|
||||
// Get original cursor position
|
||||
@ -517,7 +515,7 @@ func (window *Window) handleKeyInput(ev *tcell.EventKey) {
|
||||
}
|
||||
}
|
||||
|
||||
func (window *Window) handleMouseInput(ev *tcell.EventMouse) {
|
||||
func (window *Window) mouseInput(ev *tcell.EventMouse) {
|
||||
mouseX, mouseY := ev.Position()
|
||||
|
||||
// Left click was pressed
|
||||
|
Loading…
x
Reference in New Issue
Block a user