mirror of https://github.com/liamg/aminal.git
commit
3f5260eff5
|
@ -14,7 +14,8 @@ Ensure you have your latest graphics card drivers installed before use.
|
||||||
|
|
||||||
## Contextual Hints
|
## Contextual Hints
|
||||||
|
|
||||||

|

|
||||||
|

|
||||||
|
|
||||||
## Built-in Powerline Fonts
|
## Built-in Powerline Fonts
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,6 @@ func (a *annotation) render(gui *GUI) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gui.textbox(a.hint.StartX+1, a.hint.StartY+3, a.hint.Description)
|
gui.textbox(a.hint.StartX+1, a.hint.StartY+3, a.hint.Description, a.hint.ForegroundColour, a.hint.BackgroundColour)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -265,7 +265,10 @@ Buffer Size: %d lines
|
||||||
gui.terminal.ActiveBuffer().ViewWidth(),
|
gui.terminal.ActiveBuffer().ViewWidth(),
|
||||||
gui.terminal.ActiveBuffer().ViewHeight(),
|
gui.terminal.ActiveBuffer().ViewHeight(),
|
||||||
gui.terminal.ActiveBuffer().Height(),
|
gui.terminal.ActiveBuffer().Height(),
|
||||||
))
|
),
|
||||||
|
[3]float32{0, 1, 0},
|
||||||
|
[3]float32{0, 0, 0},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
gui.window.SwapBuffers()
|
gui.window.SwapBuffers()
|
||||||
|
|
12
gui/mouse.go
12
gui/mouse.go
|
@ -27,13 +27,11 @@ func (gui *GUI) mouseMoveCallback(w *glfw.Window, xpos float64, ypos float64) {
|
||||||
gui.terminal.ActiveBuffer().EndSelection(x, y, false)
|
gui.terminal.ActiveBuffer().EndSelection(x, y, false)
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if gui.terminal.UsingMainBuffer() {
|
hint := gui.terminal.ActiveBuffer().GetHintAtPosition(x, y)
|
||||||
hint := gui.terminal.ActiveBuffer().GetHintAtPosition(x, y)
|
if hint != nil {
|
||||||
if hint != nil {
|
gui.setOverlay(newAnnotation(hint))
|
||||||
gui.setOverlay(newAnnotation(hint))
|
} else {
|
||||||
} else {
|
gui.setOverlay(nil)
|
||||||
gui.setOverlay(nil)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ func (gui *GUI) setOverlay(m overlay) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *GUI) renderOverlay() {
|
func (gui *GUI) renderOverlay() {
|
||||||
if gui.overlay == nil || !gui.terminal.UsingMainBuffer() {
|
if gui.overlay == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"github.com/liamg/aminal/buffer"
|
"github.com/liamg/aminal/buffer"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (gui *GUI) textbox(col uint16, row uint16, text string) {
|
func (gui *GUI) textbox(col uint16, row uint16, text string, fg [3]float32, bg [3]float32) {
|
||||||
|
|
||||||
lines := []string{}
|
lines := []string{}
|
||||||
line := ""
|
line := ""
|
||||||
|
@ -81,18 +81,16 @@ DONE:
|
||||||
|
|
||||||
gui.renderer.Clean()
|
gui.renderer.Clean()
|
||||||
|
|
||||||
bg := [3]float32{0, 0, 0}
|
for hx := col; hx < col+uint16(longestLine)+1; hx++ {
|
||||||
|
|
||||||
for hx := col; hx < col+uint16(longestLine)+2; hx++ {
|
|
||||||
for hy := row - 1; hy < row+uint16(len(lines))+1; hy++ {
|
for hy := row - 1; hy < row+uint16(len(lines))+1; hy++ {
|
||||||
gui.renderer.DrawCellBg(buffer.NewBackgroundCell(bg), uint(hx), uint(hy), false, nil , true)
|
gui.renderer.DrawCellBg(buffer.NewBackgroundCell(bg), uint(hx), uint(hy), false, nil, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
x := float32(col) * gui.renderer.cellWidth
|
x := float32(col) * gui.renderer.cellWidth
|
||||||
|
|
||||||
f := gui.fontMap.GetFont('X')
|
f := gui.fontMap.GetFont('X')
|
||||||
f.SetColor(0.2, 1, 0.2, 1)
|
f.SetColor(fg[0], fg[1], fg[2], 1)
|
||||||
|
|
||||||
for i, line := range lines {
|
for i, line := range lines {
|
||||||
y := float32(row+1+uint16(i)) * gui.renderer.cellHeight
|
y := float32(row+1+uint16(i)) * gui.renderer.cellHeight
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
|
@ -0,0 +1,47 @@
|
||||||
|
package hints
|
||||||
|
|
||||||
|
import (
|
||||||
|
"regexp"
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
hinters = append(hinters, hintColours)
|
||||||
|
}
|
||||||
|
|
||||||
|
func hintColours(word string, context string, wordX uint16, wordY uint16) *Hint {
|
||||||
|
|
||||||
|
item := NewHint(word, context, wordX, wordY)
|
||||||
|
|
||||||
|
if isColour(word) {
|
||||||
|
|
||||||
|
r, err := strconv.ParseInt(word[1:3], 16, 64)
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
g, err := strconv.ParseInt(word[3:5], 16, 64)
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
b, err := strconv.ParseInt(word[5:7], 16, 64)
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
item.Description = word
|
||||||
|
item.BackgroundColour = [3]float32{float32(r) / 255, float32(g) / 255, float32(b) / 255}
|
||||||
|
if (r+g+b)/3 < 128 {
|
||||||
|
item.ForegroundColour = [3]float32{1, 1, 1}
|
||||||
|
} else {
|
||||||
|
item.ForegroundColour = [3]float32{0, 0, 0}
|
||||||
|
}
|
||||||
|
return item
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func isColour(s string) bool {
|
||||||
|
re := regexp.MustCompile("#[0-9A-Fa-f]{6}")
|
||||||
|
return re.MatchString(s)
|
||||||
|
}
|
|
@ -1,11 +1,13 @@
|
||||||
package hints
|
package hints
|
||||||
|
|
||||||
type Hint struct {
|
type Hint struct {
|
||||||
Word string
|
Word string
|
||||||
StartX uint16
|
StartX uint16
|
||||||
StartY uint16
|
StartY uint16
|
||||||
Line string
|
Line string
|
||||||
Description string
|
Description string
|
||||||
|
BackgroundColour [3]float32
|
||||||
|
ForegroundColour [3]float32
|
||||||
}
|
}
|
||||||
|
|
||||||
type hinter func(word string, context string, wordX uint16, wordY uint16) *Hint
|
type hinter func(word string, context string, wordX uint16, wordY uint16) *Hint
|
||||||
|
@ -20,3 +22,14 @@ func Get(word string, context string, wordX uint16, wordY uint16) *Hint {
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewHint(word string, context string, wordX uint16, wordY uint16) *Hint {
|
||||||
|
return &Hint{
|
||||||
|
Line: context,
|
||||||
|
Word: word,
|
||||||
|
StartX: wordX,
|
||||||
|
StartY: wordY,
|
||||||
|
BackgroundColour: [3]float32{0, 0, 0},
|
||||||
|
ForegroundColour: [3]float32{0.2, 1, 0.2},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -112,12 +112,7 @@ func init() {
|
||||||
|
|
||||||
func hintPerms(word string, context string, wordX uint16, wordY uint16) *Hint {
|
func hintPerms(word string, context string, wordX uint16, wordY uint16) *Hint {
|
||||||
|
|
||||||
item := &Hint{
|
item := NewHint(word, context, wordX, wordY)
|
||||||
Line: context,
|
|
||||||
Word: word,
|
|
||||||
StartX: wordX,
|
|
||||||
StartY: wordY,
|
|
||||||
}
|
|
||||||
|
|
||||||
if wordX == 0 {
|
if wordX == 0 {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue