mirror of https://github.com/liamg/aminal.git
Underline support (#193)
* added Tab Stops support * added support for Screen Mode (DECSCNM) -- reverse colors * bug fix: cursor rendition in Origin Mode * bug fix: SGR parameters handling * Save/Restore Cursor updates. Partial charset implementation. * added Underline support * fixed underline position * underline position measured in MinY
This commit is contained in:
parent
22a5e8063a
commit
07952f7505
31
gui/gui.go
31
gui/gui.go
|
@ -19,10 +19,10 @@ import (
|
||||||
"github.com/kbinani/screenshot"
|
"github.com/kbinani/screenshot"
|
||||||
"github.com/liamg/aminal/buffer"
|
"github.com/liamg/aminal/buffer"
|
||||||
"github.com/liamg/aminal/config"
|
"github.com/liamg/aminal/config"
|
||||||
|
"github.com/liamg/aminal/platform"
|
||||||
"github.com/liamg/aminal/terminal"
|
"github.com/liamg/aminal/terminal"
|
||||||
"github.com/liamg/aminal/version"
|
"github.com/liamg/aminal/version"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"github.com/liamg/aminal/platform"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type GUI struct {
|
type GUI struct {
|
||||||
|
@ -529,6 +529,35 @@ func (gui *GUI) redraw() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
// underlines
|
||||||
|
for y := 0; y < lineCount; y++ {
|
||||||
|
|
||||||
|
if y < len(lines) {
|
||||||
|
|
||||||
|
span := 0
|
||||||
|
colour := [3]float32{0, 0, 0}
|
||||||
|
cells := lines[y].Cells()
|
||||||
|
|
||||||
|
var x int
|
||||||
|
|
||||||
|
for x = 0; x < colCount && x < len(cells); x++ {
|
||||||
|
cell := cells[x]
|
||||||
|
if span > 0 && (!cell.Attr().Underline || colour != cell.Fg()) {
|
||||||
|
gui.renderer.DrawUnderline(span, uint(x-span), uint(y), colour)
|
||||||
|
span = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
colour = cell.Fg()
|
||||||
|
if cell.Attr().Underline {
|
||||||
|
span++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if span > 0 {
|
||||||
|
gui.renderer.DrawUnderline(span, uint(x-span), uint(y), colour)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
gui.renderOverlay()
|
gui.renderOverlay()
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ func (r *OpenGLRenderer) CellHeight() float32 {
|
||||||
return r.cellHeight
|
return r.cellHeight
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *OpenGLRenderer) newRectangle(x float32, y float32, colourAttr uint32) *rectangle {
|
func (r *OpenGLRenderer) newRectangleEx(x float32, y float32, width float32, height float32, colourAttr uint32) *rectangle {
|
||||||
|
|
||||||
rect := &rectangle{}
|
rect := &rectangle{}
|
||||||
|
|
||||||
|
@ -55,8 +55,8 @@ func (r *OpenGLRenderer) newRectangle(x float32, y float32, colourAttr uint32) *
|
||||||
|
|
||||||
x = (x - halfAreaWidth) / halfAreaWidth
|
x = (x - halfAreaWidth) / halfAreaWidth
|
||||||
y = -(y - (halfAreaHeight)) / halfAreaHeight
|
y = -(y - (halfAreaHeight)) / halfAreaHeight
|
||||||
w := r.cellWidth / halfAreaWidth
|
w := width / halfAreaWidth
|
||||||
h := (r.cellHeight) / halfAreaHeight
|
h := height / halfAreaHeight
|
||||||
|
|
||||||
rect.points = [18]float32{
|
rect.points = [18]float32{
|
||||||
x, y, 0,
|
x, y, 0,
|
||||||
|
@ -91,6 +91,10 @@ func (r *OpenGLRenderer) newRectangle(x float32, y float32, colourAttr uint32) *
|
||||||
return rect
|
return rect
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *OpenGLRenderer) newRectangle(x float32, y float32, colourAttr uint32) *rectangle {
|
||||||
|
return r.newRectangleEx(x, y, r.cellWidth, r.cellHeight, colourAttr)
|
||||||
|
}
|
||||||
|
|
||||||
func (rect *rectangle) Draw() {
|
func (rect *rectangle) Draw() {
|
||||||
gl.UseProgram(rect.prog)
|
gl.UseProgram(rect.prog)
|
||||||
gl.BindVertexArray(rect.vao)
|
gl.BindVertexArray(rect.vao)
|
||||||
|
@ -228,6 +232,24 @@ func (r *OpenGLRenderer) DrawCellBg(cell buffer.Cell, col uint, row uint, cursor
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DrawUnderline draws a line under 'span' characters starting at (col, row)
|
||||||
|
func (r *OpenGLRenderer) DrawUnderline(span int, col uint, row uint, colour [3]float32) {
|
||||||
|
//calculate coordinates
|
||||||
|
x := float32(float32(col) * r.cellWidth)
|
||||||
|
y := (float32(row+1))*r.cellHeight + r.fontMap.DefaultFont().MinY()*0.25
|
||||||
|
|
||||||
|
thickness := r.cellHeight / 16
|
||||||
|
if thickness < 1 {
|
||||||
|
thickness = 1
|
||||||
|
}
|
||||||
|
rect := r.newRectangleEx(x, y, r.cellWidth*float32(span), thickness, r.colourAttr)
|
||||||
|
|
||||||
|
rect.setColour(colour)
|
||||||
|
rect.Draw()
|
||||||
|
|
||||||
|
rect.Free()
|
||||||
|
}
|
||||||
|
|
||||||
func (r *OpenGLRenderer) DrawCellText(text string, col uint, row uint, alpha float32, colour [3]float32, bold bool) {
|
func (r *OpenGLRenderer) DrawCellText(text string, col uint, row uint, alpha float32, colour [3]float32, bold bool) {
|
||||||
|
|
||||||
var f *glfont.Font
|
var f *glfont.Font
|
||||||
|
|
Loading…
Reference in New Issue