mirror of
https://github.com/felixangell/phi.git
synced 2024-09-11 07:45:30 +03:00
naming refactors to comply with go vet
This commit is contained in:
parent
a14d7d2842
commit
4fdfe4141e
@ -65,8 +65,8 @@ you will need the following libraries:
|
|||||||
|
|
||||||
If you're on Linux, you will need:
|
If you're on Linux, you will need:
|
||||||
|
|
||||||
* xsel
|
|
||||||
* xclip
|
* xclip
|
||||||
|
* xsel
|
||||||
|
|
||||||
Either works. This is for copying/pasting.
|
Either works. This is for copying/pasting.
|
||||||
|
|
||||||
|
162
gui/buffer.go
162
gui/buffer.go
@ -92,7 +92,7 @@ func (a *AutoCompleteBox) process(r rune) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *AutoCompleteBox) renderAt(x, y int, ctx *strife.Renderer) {
|
func (a *AutoCompleteBox) renderAt(x, y int, ctx *strife.Renderer) {
|
||||||
height := last_h + pad
|
height := lastCharH + pad
|
||||||
itemCount := len(a.suggestions)
|
itemCount := len(a.suggestions)
|
||||||
|
|
||||||
ctx.SetColor(strife.HexRGB(0x000000))
|
ctx.SetColor(strife.HexRGB(0x000000))
|
||||||
@ -200,18 +200,18 @@ func (s *selection) renderAt(ctx *strife.Renderer, xOff int, yOff int) {
|
|||||||
lineLen = 1
|
lineLen = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
height := (last_h + pad) - b.ey
|
height := (lastCharH + pad) - b.ey
|
||||||
|
|
||||||
// width of box should be entire line
|
// width of box should be entire line
|
||||||
width := lineLen * last_w
|
width := lineLen * lastCharW
|
||||||
|
|
||||||
// UNLESS we are on the current line
|
// UNLESS we are on the current line
|
||||||
if y == yd-1 {
|
if y == yd-1 {
|
||||||
width = s.ex * last_w
|
width = s.ex * lastCharW
|
||||||
}
|
}
|
||||||
|
|
||||||
xPos := (s.sx * last_w)
|
xPos := (s.sx * lastCharW)
|
||||||
yPos := ((s.sy + y) * (last_h + pad))
|
yPos := ((s.sy + y) * (lastCharH + pad))
|
||||||
|
|
||||||
ctx.SetColor(strife.Blue)
|
ctx.SetColor(strife.Blue)
|
||||||
ctx.Rect(b.ex+xPos, b.ey+yPos, width, height, strife.Fill)
|
ctx.Rect(b.ex+xPos, b.ey+yPos, width, height, strife.Fill)
|
||||||
@ -419,7 +419,7 @@ func (b *Buffer) deleteLine() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *Buffer) processTextInput(r rune) bool {
|
func (b *Buffer) processTextInput(r rune) bool {
|
||||||
if ALT_DOWN && r == '\t' {
|
if altDown && r == '\t' {
|
||||||
// nop, we dont want to
|
// nop, we dont want to
|
||||||
// insert tabs when we
|
// insert tabs when we
|
||||||
// alt tab out of view of this app
|
// alt tab out of view of this app
|
||||||
@ -431,22 +431,22 @@ func (b *Buffer) processTextInput(r rune) bool {
|
|||||||
// only do the alt alternatives on mac osx
|
// only do the alt alternatives on mac osx
|
||||||
// todo change this so it's not checking on every
|
// todo change this so it's not checking on every
|
||||||
// input
|
// input
|
||||||
if runtime.GOOS == "darwin" && ALT_DOWN {
|
if runtime.GOOS == "darwin" && altDown {
|
||||||
if val, ok := altAlternative[r]; ok {
|
if val, ok := altAlternative[r]; ok {
|
||||||
r = val
|
r = val
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if CAPS_LOCK {
|
if capsLockDown {
|
||||||
if unicode.IsLetter(r) {
|
if unicode.IsLetter(r) {
|
||||||
r = unicode.ToUpper(r)
|
r = unicode.ToUpper(r)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mainSuper, shortcutName := CONTROL_DOWN, "ctrl"
|
mainSuper, shortcutName := controlDown, "ctrl"
|
||||||
source := cfg.Shortcuts.Controls
|
source := cfg.Shortcuts.Controls
|
||||||
if runtime.GOOS == "darwin" {
|
if runtime.GOOS == "darwin" {
|
||||||
mainSuper, shortcutName = SUPER_DOWN, "super"
|
mainSuper, shortcutName = superDown, "super"
|
||||||
source = cfg.Shortcuts.Supers
|
source = cfg.Shortcuts.Supers
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -476,7 +476,7 @@ func (b *Buffer) processTextInput(r rune) bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if SHIFT_DOWN {
|
if shiftDown {
|
||||||
// if it's a letter convert to uppercase
|
// if it's a letter convert to uppercase
|
||||||
if unicode.IsLetter(r) {
|
if unicode.IsLetter(r) {
|
||||||
r = unicode.ToUpper(r)
|
r = unicode.ToUpper(r)
|
||||||
@ -724,7 +724,7 @@ func (b *Buffer) moveDown() {
|
|||||||
|
|
||||||
b.curs.move(offs, 1)
|
b.curs.move(offs, 1)
|
||||||
|
|
||||||
visibleLines := int(math.Ceil(float64(b.h-b.ey) / float64(last_h+pad)))
|
visibleLines := int(math.Ceil(float64(b.h-b.ey) / float64(lastCharH+pad)))
|
||||||
|
|
||||||
if b.curs.y >= visibleLines && b.curs.y-b.cam.y == visibleLines {
|
if b.curs.y >= visibleLines && b.curs.y-b.cam.y == visibleLines {
|
||||||
b.scrollDown(1)
|
b.scrollDown(1)
|
||||||
@ -821,28 +821,28 @@ func (b *Buffer) processSelection(key int) bool {
|
|||||||
// which is not an action key, therefore we return false
|
// which is not an action key, therefore we return false
|
||||||
// because it was not processed.
|
// because it was not processed.
|
||||||
func (b *Buffer) processActionKey(key int) bool {
|
func (b *Buffer) processActionKey(key int) bool {
|
||||||
if SHIFT_DOWN {
|
if shiftDown {
|
||||||
switch key {
|
switch key {
|
||||||
case sdl.K_LEFT:
|
case strife.KEY_LEFT:
|
||||||
fallthrough
|
fallthrough
|
||||||
case sdl.K_RIGHT:
|
case strife.KEY_RIGHT:
|
||||||
fallthrough
|
fallthrough
|
||||||
case sdl.K_DOWN:
|
case strife.KEY_DOWN:
|
||||||
fallthrough
|
fallthrough
|
||||||
case sdl.K_UP:
|
case strife.KEY_UP:
|
||||||
return b.processSelection(key)
|
return b.processSelection(key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch key {
|
switch key {
|
||||||
case sdl.K_CAPSLOCK:
|
case strife.KEY_CAPSLOCK:
|
||||||
CAPS_LOCK = !CAPS_LOCK
|
capsLockDown = !capsLockDown
|
||||||
|
|
||||||
case sdl.K_ESCAPE:
|
case strife.KEY_ESCAPE:
|
||||||
return true
|
return true
|
||||||
|
|
||||||
case sdl.K_RETURN:
|
case strife.KEY_RETURN:
|
||||||
if SUPER_DOWN {
|
if superDown {
|
||||||
// in sublime this goes
|
// in sublime this goes
|
||||||
// into the next block
|
// into the next block
|
||||||
// nicely indented!
|
// nicely indented!
|
||||||
@ -892,20 +892,20 @@ func (b *Buffer) processActionKey(key int) bool {
|
|||||||
b.moveDown()
|
b.moveDown()
|
||||||
b.moveToStartOfLine()
|
b.moveToStartOfLine()
|
||||||
|
|
||||||
case sdl.K_BACKSPACE:
|
case strife.KEY_BACKSPACE:
|
||||||
// HACK FIXME
|
// HACK FIXME
|
||||||
b.modified = true
|
b.modified = true
|
||||||
|
|
||||||
if SUPER_DOWN {
|
if superDown {
|
||||||
b.deleteBeforeCursor()
|
b.deleteBeforeCursor()
|
||||||
} else {
|
} else {
|
||||||
b.deletePrev()
|
b.deletePrev()
|
||||||
}
|
}
|
||||||
|
|
||||||
case sdl.K_RIGHT:
|
case strife.KEY_RIGHT:
|
||||||
currLineLength := b.table.Lines[b.curs.y].Len()
|
currLineLength := b.table.Lines[b.curs.y].Len()
|
||||||
|
|
||||||
if SUPER_DOWN {
|
if superDown {
|
||||||
for b.curs.x < currLineLength {
|
for b.curs.x < currLineLength {
|
||||||
b.moveLeft()
|
b.moveLeft()
|
||||||
}
|
}
|
||||||
@ -915,7 +915,7 @@ func (b *Buffer) processActionKey(key int) bool {
|
|||||||
// FIXME this is weird!
|
// FIXME this is weird!
|
||||||
// this will move to the next blank or underscore
|
// this will move to the next blank or underscore
|
||||||
// character
|
// character
|
||||||
if ALT_DOWN {
|
if altDown {
|
||||||
line := b.table.Lines[b.curs.y]
|
line := b.table.Lines[b.curs.y]
|
||||||
|
|
||||||
i := b.curs.x + 1 // ?
|
i := b.curs.x + 1 // ?
|
||||||
@ -945,13 +945,13 @@ func (b *Buffer) processActionKey(key int) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
b.moveRight()
|
b.moveRight()
|
||||||
case sdl.K_LEFT:
|
case strife.KEY_LEFT:
|
||||||
if SUPER_DOWN {
|
if superDown {
|
||||||
// TODO go to the nearest \t
|
// TODO go to the nearest \t
|
||||||
// if no \t (i.e. start of line) go to
|
// if no \t (i.e. start of line) go to
|
||||||
// the start of the line!
|
// the start of the line!
|
||||||
b.curs.gotoStart()
|
b.curs.gotoStart()
|
||||||
} else if ALT_DOWN {
|
} else if altDown {
|
||||||
i := b.curs.x
|
i := b.curs.x
|
||||||
for i > 0 {
|
for i > 0 {
|
||||||
currChar := b.table.Index(b.curs.y, i)
|
currChar := b.table.Index(b.curs.y, i)
|
||||||
@ -986,29 +986,29 @@ func (b *Buffer) processActionKey(key int) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
b.moveLeft()
|
b.moveLeft()
|
||||||
case sdl.K_UP:
|
case strife.KEY_UP:
|
||||||
if ALT_DOWN {
|
if altDown {
|
||||||
return b.swapLineUp()
|
return b.swapLineUp()
|
||||||
}
|
}
|
||||||
|
|
||||||
if SUPER_DOWN {
|
if superDown {
|
||||||
// go to the start of the file
|
// go to the start of the file
|
||||||
}
|
}
|
||||||
|
|
||||||
b.moveUp()
|
b.moveUp()
|
||||||
|
|
||||||
case sdl.K_DOWN:
|
case strife.KEY_DOWN:
|
||||||
if ALT_DOWN {
|
if altDown {
|
||||||
return b.swapLineDown()
|
return b.swapLineDown()
|
||||||
}
|
}
|
||||||
|
|
||||||
if SUPER_DOWN {
|
if superDown {
|
||||||
// go to the end of the file
|
// go to the end of the file
|
||||||
}
|
}
|
||||||
|
|
||||||
b.moveDown()
|
b.moveDown()
|
||||||
|
|
||||||
case sdl.K_TAB:
|
case strife.KEY_TAB:
|
||||||
// HACK FIXME
|
// HACK FIXME
|
||||||
b.modified = true
|
b.modified = true
|
||||||
|
|
||||||
@ -1025,7 +1025,7 @@ func (b *Buffer) processActionKey(key int) bool {
|
|||||||
b.moveRight()
|
b.moveRight()
|
||||||
}
|
}
|
||||||
|
|
||||||
case sdl.K_END:
|
case strife.KEY_END:
|
||||||
currLine := b.table.Lines[b.curs.y]
|
currLine := b.table.Lines[b.curs.y]
|
||||||
if b.curs.x < currLine.Len() {
|
if b.curs.x < currLine.Len() {
|
||||||
distToMove := currLine.Len() - b.curs.x
|
distToMove := currLine.Len() - b.curs.x
|
||||||
@ -1034,44 +1034,44 @@ func (b *Buffer) processActionKey(key int) bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case sdl.K_HOME:
|
case strife.KEY_HOME:
|
||||||
if b.curs.x > 0 {
|
if b.curs.x > 0 {
|
||||||
b.moveToStartOfLine()
|
b.moveToStartOfLine()
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO remove since this is handled in the keymap!
|
// TODO remove since this is handled in the keymap!
|
||||||
case sdl.K_PAGEUP:
|
case strife.KEY_PAGEUP:
|
||||||
b.scrollUp(DEFAULT_SCROLL_AMOUNT)
|
b.scrollUp(DEFAULT_SCROLL_AMOUNT)
|
||||||
for i := 0; i < DEFAULT_SCROLL_AMOUNT; i++ {
|
for i := 0; i < DEFAULT_SCROLL_AMOUNT; i++ {
|
||||||
b.moveUp()
|
b.moveUp()
|
||||||
}
|
}
|
||||||
case sdl.K_PAGEDOWN:
|
case strife.KEY_PAGEDOWN:
|
||||||
b.scrollDown(DEFAULT_SCROLL_AMOUNT)
|
b.scrollDown(DEFAULT_SCROLL_AMOUNT)
|
||||||
for i := 0; i < DEFAULT_SCROLL_AMOUNT; i++ {
|
for i := 0; i < DEFAULT_SCROLL_AMOUNT; i++ {
|
||||||
b.moveDown()
|
b.moveDown()
|
||||||
}
|
}
|
||||||
|
|
||||||
case sdl.K_DELETE:
|
case strife.KEY_DELETE:
|
||||||
b.deleteNext()
|
b.deleteNext()
|
||||||
|
|
||||||
case sdl.K_LGUI:
|
case strife.KEY_LGUI:
|
||||||
fallthrough
|
fallthrough
|
||||||
case sdl.K_RGUI:
|
case strife.KEY_RGUI:
|
||||||
fallthrough
|
fallthrough
|
||||||
|
|
||||||
case sdl.K_LALT:
|
case strife.KEY_LALT:
|
||||||
fallthrough
|
fallthrough
|
||||||
case sdl.K_RALT:
|
case strife.KEY_RALT:
|
||||||
fallthrough
|
fallthrough
|
||||||
|
|
||||||
case sdl.K_LCTRL:
|
case strife.KEY_LCTRL:
|
||||||
fallthrough
|
fallthrough
|
||||||
case sdl.K_RCTRL:
|
case strife.KEY_RCTRL:
|
||||||
fallthrough
|
fallthrough
|
||||||
|
|
||||||
case sdl.K_LSHIFT:
|
case strife.KEY_LSHIFT:
|
||||||
fallthrough
|
fallthrough
|
||||||
case sdl.K_RSHIFT:
|
case strife.KEY_RSHIFT:
|
||||||
return true
|
return true
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -1082,11 +1082,11 @@ func (b *Buffer) processActionKey(key int) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
SHIFT_DOWN bool = false
|
shiftDown = false
|
||||||
SUPER_DOWN = false // cmd on mac, ctrl on windows
|
superDown = false // cmd on mac, ctrl on windows
|
||||||
CONTROL_DOWN = false // what is this on windows?
|
controlDown = false // what is this on windows?
|
||||||
ALT_DOWN = false // option on mac
|
altDown = false // option on mac
|
||||||
CAPS_LOCK = false
|
capsLockDown = false
|
||||||
)
|
)
|
||||||
|
|
||||||
func min(a, b int) int {
|
func min(a, b int) int {
|
||||||
@ -1131,8 +1131,8 @@ func (b *Buffer) processLeftClick() {
|
|||||||
// based off the click location
|
// based off the click location
|
||||||
xPos, yPos := strife.MouseCoords()
|
xPos, yPos := strife.MouseCoords()
|
||||||
|
|
||||||
yPosToLine := (((yPos) / (last_h + pad)) + 1) + b.cam.y
|
yPosToLine := (((yPos) / (lastCharH + pad)) + 1) + b.cam.y
|
||||||
xPosToLine := ((xPos - b.ex) / (last_w)) + b.cam.x
|
xPosToLine := ((xPos - b.ex) / (lastCharW)) + b.cam.x
|
||||||
|
|
||||||
fmt.Println(yPos, " line ", yPosToLine, " - ", xPos, " char ", xPosToLine)
|
fmt.Println(yPos, " line ", yPosToLine, " - ", xPos, " char ", xPosToLine)
|
||||||
|
|
||||||
@ -1182,10 +1182,10 @@ func (b *Buffer) processInput(pred func(r int) bool) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
SHIFT_DOWN = strife.KeyPressed(sdl.K_LSHIFT) || strife.KeyPressed(sdl.K_RSHIFT)
|
shiftDown = strife.KeyPressed(sdl.K_LSHIFT) || strife.KeyPressed(sdl.K_RSHIFT)
|
||||||
SUPER_DOWN = strife.KeyPressed(sdl.K_LGUI) || strife.KeyPressed(sdl.K_RGUI)
|
superDown = strife.KeyPressed(sdl.K_LGUI) || strife.KeyPressed(sdl.K_RGUI)
|
||||||
ALT_DOWN = strife.KeyPressed(sdl.K_LALT) || strife.KeyPressed(sdl.K_RALT)
|
altDown = strife.KeyPressed(sdl.K_LALT) || strife.KeyPressed(sdl.K_RALT)
|
||||||
CONTROL_DOWN = strife.KeyPressed(sdl.K_LCTRL) || strife.KeyPressed(sdl.K_RCTRL)
|
controlDown = strife.KeyPressed(sdl.K_LCTRL) || strife.KeyPressed(sdl.K_RCTRL)
|
||||||
|
|
||||||
if strife.PollKeys() {
|
if strife.PollKeys() {
|
||||||
keyCode := strife.PopKey()
|
keyCode := strife.PopKey()
|
||||||
@ -1239,7 +1239,7 @@ type syntaxRuneInfo struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// dimensions of the last character we rendered
|
// dimensions of the last character we rendered
|
||||||
var last_w, last_h int
|
var lastCharW, lastCharH int
|
||||||
|
|
||||||
// runs up a lexer instance
|
// runs up a lexer instance
|
||||||
func lexFindMatches(matches *map[int]syntaxRuneInfo, currLine string, toMatch map[string]bool, bg uint32, fg uint32) {
|
func lexFindMatches(matches *map[int]syntaxRuneInfo, currLine string, toMatch map[string]bool, bg uint32, fg uint32) {
|
||||||
@ -1319,10 +1319,10 @@ func (b *Buffer) renderAt(ctx *strife.Renderer, rx int, ry int) {
|
|||||||
if b.cfg.Editor.Highlight_Line && b.HasFocus() {
|
if b.cfg.Editor.Highlight_Line && b.HasFocus() {
|
||||||
ctx.SetColor(strife.HexRGB(b.buffOpts.highlightLine)) // highlight_line_col?
|
ctx.SetColor(strife.HexRGB(b.buffOpts.highlightLine)) // highlight_line_col?
|
||||||
|
|
||||||
highlightLinePosY := b.ey + (ry + b.curs.ry*(last_h+pad)) - (b.cam.y * (last_h + pad))
|
highlightLinePosY := b.ey + (ry + b.curs.ry*(lastCharH+pad)) - (b.cam.y * (lastCharH + pad))
|
||||||
highlightLinePosX := b.ex + rx
|
highlightLinePosX := b.ex + rx
|
||||||
|
|
||||||
ctx.Rect(highlightLinePosX, highlightLinePosY, b.w-b.ex, (last_h+pad)-b.ey, strife.Fill)
|
ctx.Rect(highlightLinePosX, highlightLinePosY, b.w-b.ex, (lastCharH+pad)-b.ey, strife.Fill)
|
||||||
}
|
}
|
||||||
|
|
||||||
var visibleLines, visibleChars int = 50, -1
|
var visibleLines, visibleChars int = 50, -1
|
||||||
@ -1331,24 +1331,24 @@ func (b *Buffer) renderAt(ctx *strife.Renderer, rx int, ry int) {
|
|||||||
// force a render off screen
|
// force a render off screen
|
||||||
// so we can calculate the size of characters
|
// so we can calculate the size of characters
|
||||||
{
|
{
|
||||||
if int(last_h) == 0 || int(last_w) == 0 {
|
if int(lastCharH) == 0 || int(lastCharW) == 0 {
|
||||||
last_w, last_h = ctx.Text("_", -50, -50)
|
lastCharW, lastCharH = ctx.Text("_", -50, -50)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// last_h > 0 means we have done
|
// lastCharH > 0 means we have done
|
||||||
// a render.
|
// a render.
|
||||||
if int(last_h) > 0 && int(b.h) != 0 {
|
if int(lastCharH) > 0 && int(b.h) != 0 {
|
||||||
// render an extra three lines just
|
// render an extra three lines just
|
||||||
// so we dont cut anything off if its
|
// so we dont cut anything off if its
|
||||||
// not evenly divisible
|
// not evenly divisible
|
||||||
visibleLines = (int(b.h-b.ey) / int(last_h)) + 3
|
visibleLines = (int(b.h-b.ey) / int(lastCharH)) + 3
|
||||||
}
|
}
|
||||||
|
|
||||||
// calculate how many chars we can fit
|
// calculate how many chars we can fit
|
||||||
// on the screen.
|
// on the screen.
|
||||||
if int(last_w) > 0 && int(b.w) != 0 {
|
if int(lastCharW) > 0 && int(b.w) != 0 {
|
||||||
visibleChars = (int(b.w-b.ex) / int(last_w)) - 3
|
visibleChars = (int(b.w-b.ex) / int(lastCharW)) - 3
|
||||||
}
|
}
|
||||||
|
|
||||||
start := b.cam.y
|
start := b.cam.y
|
||||||
@ -1371,9 +1371,9 @@ func (b *Buffer) renderAt(ctx *strife.Renderer, rx int, ry int) {
|
|||||||
{
|
{
|
||||||
cursorWidth := b.cfg.Cursor.GetCaretWidth()
|
cursorWidth := b.cfg.Cursor.GetCaretWidth()
|
||||||
if cursorWidth == -1 {
|
if cursorWidth == -1 {
|
||||||
cursorWidth = last_w
|
cursorWidth = lastCharW
|
||||||
}
|
}
|
||||||
cursorHeight := last_h + pad
|
cursorHeight := lastCharH + pad
|
||||||
|
|
||||||
b.curs.SetSize(cursorWidth, cursorHeight)
|
b.curs.SetSize(cursorWidth, cursorHeight)
|
||||||
}
|
}
|
||||||
@ -1445,18 +1445,18 @@ func (b *Buffer) renderAt(ctx *strife.Renderer, rx int, ry int) {
|
|||||||
characterColor = charColouring{0, b.buffOpts.cursorInvert}
|
characterColor = charColouring{0, b.buffOpts.cursorInvert}
|
||||||
}
|
}
|
||||||
|
|
||||||
lineHeight := last_h + pad
|
lineHeight := lastCharH + pad
|
||||||
xPos := b.ex + (rx + ((x_col - 1) * last_w))
|
xPos := b.ex + (rx + ((x_col - 1) * lastCharW))
|
||||||
yPos := b.ey + (ry + (y_col * lineHeight)) + halfPad
|
yPos := b.ey + (ry + (y_col * lineHeight)) + halfPad
|
||||||
|
|
||||||
// todo render background
|
// todo render background
|
||||||
|
|
||||||
ctx.SetColor(strife.HexRGB(characterColor.fg))
|
ctx.SetColor(strife.HexRGB(characterColor.fg))
|
||||||
last_w, last_h = ctx.Text(string(char), xPos, yPos)
|
lastCharW, lastCharH = ctx.Text(string(char), xPos, yPos)
|
||||||
|
|
||||||
if DEBUG_MODE {
|
if DEBUG_MODE {
|
||||||
ctx.SetColor(strife.HexRGB(0xff00ff))
|
ctx.SetColor(strife.HexRGB(0xff00ff))
|
||||||
ctx.Rect(xPos, yPos, last_w, last_h, strife.Line)
|
ctx.Rect(xPos, yPos, lastCharW, lastCharH, strife.Line)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1466,9 +1466,9 @@ func (b *Buffer) renderAt(ctx *strife.Renderer, rx int, ry int) {
|
|||||||
// how many chars we need
|
// how many chars we need
|
||||||
numLinesCharWidth := len(string(numLines)) + 2
|
numLinesCharWidth := len(string(numLines)) + 2
|
||||||
|
|
||||||
gutterWidth := last_w*numLinesCharWidth + (gutterPadPx * 2)
|
gutterWidth := lastCharW*numLinesCharWidth + (gutterPadPx * 2)
|
||||||
|
|
||||||
lineHeight := last_h + pad
|
lineHeight := lastCharH + pad
|
||||||
yPos := ((ry + y_col) * lineHeight) + halfPad
|
yPos := ((ry + y_col) * lineHeight) + halfPad
|
||||||
|
|
||||||
// render the line numbers
|
// render the line numbers
|
||||||
@ -1491,7 +1491,7 @@ func (b *Buffer) renderAt(ctx *strife.Renderer, rx int, ry int) {
|
|||||||
|
|
||||||
if b.autoComplete.hasSuggestions() {
|
if b.autoComplete.hasSuggestions() {
|
||||||
|
|
||||||
xPos := b.ex + (rx + b.curs.rx*last_w) - (b.cam.x * last_w)
|
xPos := b.ex + (rx + b.curs.rx*lastCharW) - (b.cam.x * lastCharW)
|
||||||
yPos := b.ey + (ry + b.curs.ry*b.curs.height) - (b.cam.y * b.curs.height)
|
yPos := b.ey + (ry + b.curs.ry*b.curs.height) - (b.cam.y * b.curs.height)
|
||||||
|
|
||||||
autoCompleteBoxHeight := len(b.autoComplete.suggestions) * b.curs.height
|
autoCompleteBoxHeight := len(b.autoComplete.suggestions) * b.curs.height
|
||||||
|
@ -25,7 +25,7 @@ func CloseBuffer(v *View, commands []string) bool {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
// save the buffer!
|
// save the buffer!
|
||||||
Save(v, []string{})
|
// Save(v, []string{})
|
||||||
}
|
}
|
||||||
|
|
||||||
v.removeBuffer(b.index)
|
v.removeBuffer(b.index)
|
||||||
|
@ -66,7 +66,7 @@ func (c *Cursor) moveRender(x, y, rx, ry int) {
|
|||||||
func (c *Cursor) Render(ctx *strife.Renderer, xOff, yOff int) {
|
func (c *Cursor) Render(ctx *strife.Renderer, xOff, yOff int) {
|
||||||
b := c.parent
|
b := c.parent
|
||||||
|
|
||||||
xPos := b.ex + (xOff + c.rx*last_w) - (b.cam.x * last_w)
|
xPos := b.ex + (xOff + c.rx*lastCharW) - (b.cam.x * lastCharW)
|
||||||
yPos := b.ey + (yOff + c.ry*c.height) - (b.cam.y * c.height)
|
yPos := b.ey + (yOff + c.ry*c.height) - (b.cam.y * c.height)
|
||||||
|
|
||||||
ctx.SetColor(strife.HexRGB(b.buffOpts.cursor))
|
ctx.SetColor(strife.HexRGB(b.buffOpts.cursor))
|
||||||
|
11
gui/view.go
11
gui/view.go
@ -77,7 +77,6 @@ func NewView(width, height int, conf *cfg.TomlConfig) *View {
|
|||||||
// modified so we specify a reload event
|
// modified so we specify a reload event
|
||||||
buff, ok := view.bufferMap[event.Name]
|
buff, ok := view.bufferMap[event.Name]
|
||||||
if !ok {
|
if !ok {
|
||||||
panic(fmt.Sprintf("no such buffer for file '%s'", event.Name))
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,18 +239,18 @@ func (n *View) OnInit() {
|
|||||||
func (n *View) OnUpdate() bool {
|
func (n *View) OnUpdate() bool {
|
||||||
dirty := false
|
dirty := false
|
||||||
|
|
||||||
CONTROL_DOWN = strife.KeyPressed(sdl.K_LCTRL) || strife.KeyPressed(sdl.K_RCTRL)
|
controlDown = strife.KeyPressed(sdl.K_LCTRL) || strife.KeyPressed(sdl.K_RCTRL)
|
||||||
SUPER_DOWN = strife.KeyPressed(sdl.K_LGUI) || strife.KeyPressed(sdl.K_RGUI)
|
superDown = strife.KeyPressed(sdl.K_LGUI) || strife.KeyPressed(sdl.K_RGUI)
|
||||||
|
|
||||||
shortcutName := "ctrl"
|
shortcutName := "ctrl"
|
||||||
source := cfg.Shortcuts.Controls
|
source := cfg.Shortcuts.Controls
|
||||||
|
|
||||||
if strife.PollKeys() && (SUPER_DOWN || CONTROL_DOWN) {
|
if strife.PollKeys() && (superDown || controlDown) {
|
||||||
if runtime.GOOS == "darwin" {
|
if runtime.GOOS == "darwin" {
|
||||||
if SUPER_DOWN {
|
if superDown {
|
||||||
source = cfg.Shortcuts.Supers
|
source = cfg.Shortcuts.Supers
|
||||||
shortcutName = "super"
|
shortcutName = "super"
|
||||||
} else if CONTROL_DOWN {
|
} else if controlDown {
|
||||||
source = cfg.Shortcuts.Controls
|
source = cfg.Shortcuts.Controls
|
||||||
shortcutName = "control"
|
shortcutName = "control"
|
||||||
}
|
}
|
||||||
|
@ -19,5 +19,5 @@ func NewToken(lexeme string, kind TokenType, start int) *Token {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *Token) String() string {
|
func (t *Token) String() string {
|
||||||
return fmt.Sprintf("lexeme: %s, type %s, at pos %d", t.Lexeme, t.Type, t.Start)
|
return fmt.Sprintf("lexeme: %s, type %s, at pos %d", t.Lexeme, string(t.Type), t.Start)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user