Ran go fmt *.go
on all sources
This commit is contained in:
parent
e115855491
commit
3982628653
8
main.go
8
main.go
@ -4,9 +4,9 @@ import (
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"io/fs"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"runtime"
|
||||
"runtime/pprof"
|
||||
@ -186,7 +186,7 @@ func main() {
|
||||
tabContainer.AddTab("noname", textEdit)
|
||||
|
||||
changeFocus(tabContainer)
|
||||
tabContainer.FocusTab(tabContainer.GetTabCount()-1)
|
||||
tabContainer.FocusTab(tabContainer.GetTabCount() - 1)
|
||||
}}, &ui.ItemEntry{Name: "Open...", Shortcut: "Ctrl+O", Callback: func() {
|
||||
callback := func(filePaths []string) {
|
||||
var errOccurred bool
|
||||
@ -214,7 +214,7 @@ func main() {
|
||||
dialog = nil // Hide the file selector
|
||||
changeFocus(tabContainer)
|
||||
if tabContainer.GetTabCount() > 0 {
|
||||
tabContainer.FocusTab(tabContainer.GetTabCount()-1)
|
||||
tabContainer.FocusTab(tabContainer.GetTabCount() - 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -426,7 +426,7 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
if ev.Modifiers() & tcell.ModCtrl != 0 {
|
||||
if ev.Modifiers()&tcell.ModCtrl != 0 {
|
||||
handled := menuBar.HandleEvent(ev)
|
||||
if handled {
|
||||
continue // Avoid passing the event to the focusedComponent
|
||||
|
@ -62,7 +62,6 @@ type Buffer interface {
|
||||
// the last rune before the line delimiter.
|
||||
ClampLineCol(line, col int) (int, int)
|
||||
|
||||
|
||||
// LineColToPos returns the index of the byte at line, col. If line is less than
|
||||
// zero, or more than the number of available lines, the function will panic. If
|
||||
// col is less than zero, the function will panic. If col is greater than the
|
||||
|
@ -23,7 +23,7 @@ func (c *Colorscheme) GetStyle(s Syntax) tcell.Style {
|
||||
}
|
||||
}
|
||||
|
||||
return tcell.StyleDefault; // No value for Default; use default style.
|
||||
return tcell.StyleDefault // No value for Default; use default style.
|
||||
}
|
||||
|
||||
type RegexpRegion struct {
|
||||
@ -111,9 +111,9 @@ func (h *Highlighter) updateLines(startLine, endLine int) {
|
||||
if indexes != nil {
|
||||
for i := range indexes {
|
||||
startLine, startCol := h.Buffer.PosToLineCol(indexes[i][0] + startPos)
|
||||
endLine, endCol := h.Buffer.PosToLineCol(indexes[i][1]-1 + startPos)
|
||||
endLine, endCol := h.Buffer.PosToLineCol(indexes[i][1] - 1 + startPos)
|
||||
|
||||
match := Match { startCol, endLine, endCol, v }
|
||||
match := Match{startCol, endLine, endCol, v}
|
||||
|
||||
h.lineMatches[startLine] = append(h.lineMatches[startLine], match) // Unsorted
|
||||
}
|
||||
@ -138,7 +138,7 @@ func (h *Highlighter) UpdateInvalidatedLines(startLine, endLine int) {
|
||||
|
||||
// Keep endLine clamped
|
||||
if endLine >= len(h.lineMatches) {
|
||||
endLine = len(h.lineMatches)-1
|
||||
endLine = len(h.lineMatches) - 1
|
||||
}
|
||||
|
||||
// Move endLine back to first line at or before endLine with invalidated changes
|
||||
|
@ -99,7 +99,7 @@ func (b *RopeBuffer) Line(line int) []byte {
|
||||
func (b *RopeBuffer) Slice(startLine, startCol, endLine, endCol int) []byte {
|
||||
endPos := b.LineColToPos(endLine, endCol)
|
||||
if length := (*rope.Node)(b).Len(); endPos >= length {
|
||||
endPos = length-1
|
||||
endPos = length - 1
|
||||
}
|
||||
return (*rope.Node)(b).Slice(b.LineColToPos(startLine, startCol), endPos+1)
|
||||
}
|
||||
@ -275,7 +275,7 @@ func (b *RopeBuffer) RunesInLine(line int) int {
|
||||
func (b *RopeBuffer) ClampLineCol(line, col int) (int, int) {
|
||||
if line < 0 {
|
||||
line = 0
|
||||
} else if lines := b.Lines()-1; line > lines {
|
||||
} else if lines := b.Lines() - 1; line > lines {
|
||||
line = lines
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ func TestRopePosToLineCol(t *testing.T) {
|
||||
t.Errorf("Expected startCol == 0, got %v", startCol)
|
||||
}
|
||||
|
||||
endPos := buf.Len()-1
|
||||
endPos := buf.Len() - 1
|
||||
endLine, endCol := buf.PosToLineCol(endPos)
|
||||
t.Logf("endPos = %v", endPos)
|
||||
if endLine != 3 {
|
||||
|
@ -90,7 +90,7 @@ func DrawWindow(s tcell.Screen, x, y, width, height int, title string, theme *Th
|
||||
headerStyle := theme.GetOrDefault("WindowHeader")
|
||||
|
||||
DrawRect(s, x, y, width, 1, ' ', headerStyle) // Draw header background
|
||||
DrawStr(s, x + width/2 - len(title)/2, y, title, headerStyle) // Draw header title
|
||||
DrawStr(s, x+width/2-len(title)/2, y, title, headerStyle) // Draw header title
|
||||
|
||||
DrawRect(s, x, y+1, width, height-1, ' ', theme.GetOrDefault("Window")) // Draw body
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ func (f *InputField) insert(dst []byte, at int, src ...byte) []byte {
|
||||
copy(dstn[at:], src)
|
||||
return dstn
|
||||
}
|
||||
dstn := make([]byte, len(dst) + len(src))
|
||||
dstn := make([]byte, len(dst)+len(src))
|
||||
copy(dstn, dst[:at])
|
||||
copy(dstn[at:], src)
|
||||
copy(dstn[at+len(src):], dst[at:])
|
||||
|
@ -118,7 +118,7 @@ func (d *MessageDialog) SetPos(x, y int) {
|
||||
func (d *MessageDialog) GetMinSize() (int, int) {
|
||||
lines := strings.Count(d.messageWrapped, "\n") + 1
|
||||
|
||||
return Max(len(d.Title)+2, 30), 2+lines+2
|
||||
return Max(len(d.Title)+2, 30), 2 + lines + 2
|
||||
}
|
||||
|
||||
func (d *MessageDialog) GetSize() (int, int) {
|
||||
|
@ -9,9 +9,9 @@ import (
|
||||
"strings"
|
||||
"unicode/utf8"
|
||||
|
||||
"github.com/mattn/go-runewidth"
|
||||
"github.com/fivemoreminix/qedit/ui/buffer"
|
||||
"github.com/gdamore/tcell/v2"
|
||||
"github.com/mattn/go-runewidth"
|
||||
)
|
||||
|
||||
// A Selection represents a region of the buffer to be selected for text editing
|
||||
@ -91,10 +91,10 @@ loop:
|
||||
t.Buffer = buffer.NewRopeBuffer(contents)
|
||||
|
||||
// TODO: replace with automatic determination of language via filetype
|
||||
lang := &buffer.Language {
|
||||
lang := &buffer.Language{
|
||||
Name: "Go",
|
||||
Filetypes: []string{".go"},
|
||||
Rules: map[*buffer.RegexpRegion]buffer.Syntax {
|
||||
Rules: map[*buffer.RegexpRegion]buffer.Syntax{
|
||||
&buffer.RegexpRegion{Start: regexp.MustCompile("\\/\\/.*")}: buffer.Comment,
|
||||
&buffer.RegexpRegion{Start: regexp.MustCompile("\".*?\"")}: buffer.String,
|
||||
&buffer.RegexpRegion{
|
||||
@ -115,7 +115,7 @@ loop:
|
||||
},
|
||||
}
|
||||
|
||||
colorscheme := &buffer.Colorscheme {
|
||||
colorscheme := &buffer.Colorscheme{
|
||||
buffer.Default: tcell.Style{}.Foreground(tcell.ColorLightGray).Background(tcell.ColorBlack),
|
||||
buffer.Comment: tcell.Style{}.Foreground(tcell.ColorGray).Background(tcell.ColorBlack),
|
||||
buffer.String: tcell.Style{}.Foreground(tcell.ColorOlive).Background(tcell.ColorBlack),
|
||||
@ -275,7 +275,7 @@ func (t *TextEdit) SetLineCol(line, col int) {
|
||||
line, col = t.Buffer.ClampLineCol(line, col)
|
||||
|
||||
// Handle hard tabs
|
||||
tabOffset := t.getTabCountInLineAtCol(line, col) * (t.TabSize-1) // Offset for the current line from hard tabs (temporary; purely visual)
|
||||
tabOffset := t.getTabCountInLineAtCol(line, col) * (t.TabSize - 1) // Offset for the current line from hard tabs (temporary; purely visual)
|
||||
|
||||
// Scroll the screen when going to lines out of view
|
||||
if line >= t.scrolly+t.height-1 { // If the new line is below view...
|
||||
@ -386,7 +386,7 @@ func (t *TextEdit) Draw(s tcell.Screen) {
|
||||
selectedStyle := t.Theme.GetOrDefault("TextEditSelected")
|
||||
columnStyle := t.Theme.GetOrDefault("TextEditColumn")
|
||||
|
||||
t.Highlighter.UpdateInvalidatedLines(t.scrolly, t.scrolly + (t.height-1))
|
||||
t.Highlighter.UpdateInvalidatedLines(t.scrolly, t.scrolly+(t.height-1))
|
||||
|
||||
var tabBytes []byte
|
||||
if t.UseHardTabs {
|
||||
@ -410,20 +410,20 @@ func (t *TextEdit) Draw(s tcell.Screen) {
|
||||
|
||||
// When iterating lineTabs: the value at i is
|
||||
// the rune index the tab was found at.
|
||||
// var lineTabs [128]int // Rune index for each hard tab '\t' in lineBytes
|
||||
// var tabs int // Length of lineTabs (number of hard tabs)
|
||||
// var lineTabs [128]int // Rune index for each hard tab '\t' in lineBytes
|
||||
// var tabs int // Length of lineTabs (number of hard tabs)
|
||||
if t.UseHardTabs {
|
||||
// var ri int // rune index
|
||||
// var i int
|
||||
// for i < len(lineBytes) {
|
||||
// r, size := utf8.DecodeRune(lineBytes[i:])
|
||||
// if r == '\t' {
|
||||
// lineTabs[tabs] = ri
|
||||
// tabs++
|
||||
// }
|
||||
// i += size
|
||||
// ri++
|
||||
// }
|
||||
// var ri int // rune index
|
||||
// var i int
|
||||
// for i < len(lineBytes) {
|
||||
// r, size := utf8.DecodeRune(lineBytes[i:])
|
||||
// if r == '\t' {
|
||||
// lineTabs[tabs] = ri
|
||||
// tabs++
|
||||
// }
|
||||
// i += size
|
||||
// ri++
|
||||
// }
|
||||
lineBytes = bytes.ReplaceAll(lineBytes, []byte{'\t'}, tabBytes)
|
||||
}
|
||||
|
||||
@ -475,7 +475,7 @@ func (t *TextEdit) Draw(s tcell.Screen) {
|
||||
return ridx
|
||||
}
|
||||
|
||||
for col < t.x + t.width { // For each column in view...
|
||||
for col < t.x+t.width { // For each column in view...
|
||||
var r rune = ' ' // Rune to draw this iteration
|
||||
var size int = 1 // Size of the rune (in bytes)
|
||||
var selected bool // Whether this rune should be styled as selected
|
||||
|
Loading…
x
Reference in New Issue
Block a user