diff --git a/desktop/go.mod b/desktop/go.mod index ac79a91381..feeebf6e10 100644 --- a/desktop/go.mod +++ b/desktop/go.mod @@ -9,7 +9,7 @@ toolchain go1.27.3 require ( github.com/creack/pty v1.1.24 github.com/tailscale/hujson v0.0.0-20260727124030-b80ff77dac4f - github.com/vivaui/viva v0.6.6-0.20261117144308-d36f87e2234a + github.com/vivaui/viva v0.6.6-0.20261118022843-059256b5ba10 github.com/zalando/go-keyring v0.2.8 golang.org/x/sys v0.50.0 ) @@ -20,4 +20,4 @@ require ( github.com/godbus/dbus/v5 v5.2.2 // indirect ) -replace github.com/vivaui/viva => github.com/Lithe-IDEA/viva v0.6.6-0.20261117151934-c1f24ffa3d8a +replace github.com/vivaui/viva => github.com/Lithe-IDEA/viva v0.6.6-0.20261118033718-113224d5ae69 diff --git a/desktop/go.sum b/desktop/go.sum index 9564694840..17ddc7f347 100644 --- a/desktop/go.sum +++ b/desktop/go.sum @@ -1,5 +1,5 @@ -github.com/Lithe-IDEA/viva v0.6.6-0.20261117151934-c1f24ffa3d8a h1:H8/n3hWP1D94Hq4q8tKGkcQRwkLT23xRbMnjE542kNE= -github.com/Lithe-IDEA/viva v0.6.6-0.20261117151934-c1f24ffa3d8a/go.mod h1:e9In6+J77G7B9ow4enZ2FSOFh7U3q4cQ5iJr3Qn/Olk= +github.com/Lithe-IDEA/viva v0.6.6-0.20261118033718-113224d5ae69 h1:tdXFBBZWrsCqImJ+QUcKNVkGkMe3AJZ+QX7F8/l6hKk= +github.com/Lithe-IDEA/viva v0.6.6-0.20261118033718-113224d5ae69/go.mod h1:e9In6+J77G7B9ow4enZ2FSOFh7U3q4cQ5iJr3Qn/Olk= github.com/creack/pty v1.1.24 h1:bJrF4RRfyJnbTJqzRLHzcGaZK1NeM5kTC9jGgovnR1s= github.com/creack/pty v1.1.24/go.mod h1:08sCNb52WyoAwi2QDyzUCTgcvVFhUzewun7wtTfvcwE= github.com/danieljoos/wincred v1.2.3 h1:v7dZC2x32Ut3nEfRH+vhoZGvN72+dQ/snVXo/vMFLdQ= diff --git a/desktop/internal/textview/cells.go b/desktop/internal/textview/cells.go deleted file mode 100644 index 5e38189a5f..0000000000 --- a/desktop/internal/textview/cells.go +++ /dev/null @@ -1,55 +0,0 @@ -package textview - -import ( - "unicode/utf8" - - "github.com/1lck/Lithe-IDEA/desktop/internal/term" -) - -// tabSize is how many columns a tab stop is apart, as in the console the old client drew. -const tabSize = 4 - -// runeCells is how many columns of the fixed-pitch grid r takes when it starts at -// column at: a tab reaches the next stop, a carriage return takes none, a wide character -// two and a combining mark none, as the editor counts them (editorview's runeCells). -func runeCells(r rune, at int) int { - switch { - case r == '\t': - return tabSize - at%tabSize - case r == '\r': - return 0 - case r < 0x80: - return 1 - } - return term.Width(r) -} - -// cellsOf is how many columns text takes, starting at column at. -func cellsOf(text string, at int) int { - cells := at - for _, r := range text { - cells += runeCells(r, cells) - } - return cells - at -} - -// byteAt is the byte offset of text that a point column columns from its start names. -// nearest picks the boundary closest to the point, as a caret is placed; otherwise it -// is the start of the character the point is on, as a word is picked. -func byteAt(text string, column float32, nearest bool) int { - cells := 0 - for i := 0; i < len(text); { - r, size := utf8.DecodeRuneInString(text[i:]) - width := runeCells(r, cells) - end := float32(cells + width) - if column < end { - if nearest && width > 0 && column >= float32(cells)+float32(width)/2 { - return i + size - } - return i - } - cells += width - i += size - } - return len(text) -} diff --git a/desktop/internal/textview/paint.go b/desktop/internal/textview/paint.go deleted file mode 100644 index 086ab4d76b..0000000000 --- a/desktop/internal/textview/paint.go +++ /dev/null @@ -1,305 +0,0 @@ -package textview - -import ( - "math" - "unicode/utf8" - - "github.com/vivaui/viva/gfx" - "github.com/vivaui/viva/ui" -) - -// labelWidth is how wide one label of a row is at most, as the editor cuts its rows -// (editorview's labelWidth), so a very long line is not one huge texture. -const labelWidth = float32(2048) - -// replacementChar is what a byte that is not UTF-8 shows. -const replacementChar = "\uFFFD" - -// painter gathers the runs of one label of a row. -type painter struct { - v *View - canvas *gfx.Canvas - runs []gfx.TextRun - style gfx.TextStyle - left float32 - y float32 - line int - // fit is how many cells of the row are drawn before the ellipsis of a line cut short, - // and -1 when the row is drawn whole. - fit int -} - -// paint draws the rows on screen: the selection behind them, then each row on the -// fixed-pitch grid in its spans' colors. It declares the view's hit again with the text -// cursor, and the links with the hand. -func (v *View) paint(dc *ui.DrawContext) { - canvas := dc.Canvas - src := v.spec.Source - if src == nil { - return - } - v.rect = dc.Rect - v.clip = visible(canvas, dc.Rect) - if v.spec.Wrap && dc.Rect.Width != v.width { - v.width = dc.Rect.Width - v.layout(v.width) - canvas.RequestFrame() // the rows changed, and with them the height declared - } - if v.pressed && v.moved { - v.extendTo(v.pointer) - } - canvas.HitWithOptions(v.id, v.clip, dc.Label, gfx.HitOptions{Role: gfx.RoleGroup, Cursor: gfx.PointerCursorText}) - from, to := v.rowRange() - selFrom, selTo, selected := v.Selection.Range(src) - p := &painter{v: v, canvas: canvas, style: v.spec.Font, left: v.rect.X + v.spec.PadX} - p.style.Mono = true - limit := max(int(labelWidth/v.cellW), 1) - cols := max(int(math.Ceil(float64((v.clip.X+v.clip.Width-p.left)/v.cellW))), 0) - // The columns a line fits in before its trail, less the pixels a label is drawn wider. - room := int((v.rect.Width - 2*v.spec.PadX - 2) / v.cellW) - v.trails = v.trails[:0] - for index := from; index < to; index++ { - line, start, end := v.rowBytes(index) - text := src.Line(line) - p.line = line - p.y = v.rect.Y + v.spec.PadY + float32(index)*v.lineH - if v.spec.LineBackground != nil { - if color := v.spec.LineBackground(line); color.Alpha > 0 { - canvas.Fill(gfx.Rect{X: v.rect.X, Y: p.y, Width: v.rect.Width, Height: v.lineH}, color) - } - } - var trail Trail - if v.spec.Trail != nil && start == 0 { - trail = v.spec.Trail(line) - } - v.spans = v.spans[:0] - if v.spec.Spans != nil && text != "" { - v.spans = v.spec.Spans(line, text, v.spans) - } - p.fit = -1 - if v.spec.Ellipsis && !v.spec.Wrap { - fit := room - if trail.Text != "" { - fit -= v.trailCells(line) - } - if fit = max(fit, 1); cellsOf(text, 0) > fit { - p.fit = fit - 1 - } - } - p.decorate(text, start, end) - if selected && line >= selFrom.Line && line <= selTo.Line { - v.paintSelection(canvas, text, line, start, end, index, selFrom, selTo, p.left, p.y, p.fit) - } - if p.fit < 0 { - p.row(text, start, end, cols, limit) - } else { - p.cut(text, start, end, min(cols, p.fit), limit) - } - if trail.Text != "" { - p.trail(line, trail) - } - } -} - -// cut draws a row cut short: the columns before fit, then the ellipsis in the color of the -// span the cut fell in. -func (p *painter) cut(text string, start, end, fit, limit int) { - stop := p.row(text, start, end, fit, limit) - color := p.style.Color - for _, span := range p.v.spans { - if span.From <= stop && stop < span.To { - color = p.spanColor(span) - break - } - } - p.runs = append(p.runs, gfx.TextRun{Bytes: int32(len(ellipsis)), Cells: 1, Color: color}) - p.flush(ellipsis, p.fit, p.fit+1) -} - -// trail draws line n's trail at the view's right edge, centered on the row, and keeps where -// a Button trail went so a click on it presses it. -func (p *painter) trail(n int, t Trail) { - v := p.v - width := p.canvas.TextWidthStyle(t.Text, t.Style) - height := t.Style.Size + 7 // the height of one line of a ui.Text - rect := gfx.Rect{X: v.rect.X + v.rect.Width - v.spec.PadX - width, Y: p.y + (v.lineH-height)/2, Width: width + 1, Height: height} - p.canvas.Label(t.Text, rect, t.Style) - if t.Button { - hit := gfx.Rect{X: rect.X, Y: p.y, Width: rect.Width, Height: v.lineH} - p.canvas.HitWithOptions(v.id, hit, t.Text, gfx.HitOptions{Role: gfx.RoleButton, Cursor: gfx.PointerCursorHand}) - v.trails = append(v.trails, trailHit{line: n, rect: hit}) - } -} - -// spanColor is the color a span is drawn in: its Hover color while the pointer is over its -// link. -func (p *painter) spanColor(span Span) gfx.Color { - v := p.v - if span.Link && span.Hover.Alpha > 0 && v.hovering && v.hover.Byte == span.From && p.line == v.hover.Line { - return span.Hover - } - return span.Color -} - -// visible is the part of r inside every clip the canvas paints with. -func visible(canvas *gfx.Canvas, r gfx.Rect) gfx.Rect { - for _, clip := range canvas.Clips() { - b := clip.Bounds - x0, y0 := max(r.X, b.X), max(r.Y, b.Y) - x1, y1 := min(r.X+r.Width, b.X+b.Width), min(r.Y+r.Height, b.Y+b.Height) - r = gfx.Rect{X: x0, Y: y0, Width: max(x1-x0, 0), Height: max(y1-y0, 0)} - } - return r -} - -// paintSelection fills the selected part of a row. A selection that goes on past the -// line's end covers one cell more, for the newline it holds. -func (v *View) paintSelection(canvas *gfx.Canvas, text string, line, start, end, index int, from, to Point, left, y float32, fit int) { - a, b := start, end - if line == from.Line { - a = max(a, from.Byte) - } - if line == to.Line { - b = min(b, to.Byte) - } - if a > b || a == b && !(line < to.Line && v.lastRow(index) && a == end) { - return - } - x0 := cellsOf(text[start:a], 0) - x1 := x0 + cellsOf(text[a:b], x0) - if line < to.Line && v.lastRow(index) && b == end { - x1++ - } - if fit >= 0 { - // A line cut short is selected up to its ellipsis, which stands for the rest. - x0, x1 = min(x0, fit+1), min(x1, fit+1) - if x0 >= x1 { - return - } - } - canvas.Fill(gfx.Rect{X: left + float32(x0)*v.cellW, Y: y, Width: float32(x1-x0) * v.cellW, Height: v.lineH}, v.spec.Selection) -} - -// row draws the bytes start to end of a line, the columns before cols of it, as labels -// of at most limit columns: each character on its cells, in the color of the span it is -// in. A tab or a control character leaves its cells empty; a combining mark is not drawn. -func (p *painter) row(text string, start, end, cols, limit int) int { - v := p.v - span := 0 - cells := 0 - run, runASCII := -1, false - label, labelEnd, labelAt, labelTo := -1, 0, start, start - for i := start; i < end; { - at := i - r, size := utf8.DecodeRuneInString(text[i:]) - i += size - width := runeCells(r, cells) - if width == 0 { - p.flush(text[labelAt:labelTo], label, labelEnd) - label = -1 - continue - } - if cells >= cols || p.fit >= 0 && cells+width > cols { - p.flush(text[labelAt:labelTo], label, labelEnd) - return at - } - for span < len(v.spans) && v.spans[span].To <= at { - span++ - } - var style Span - styled := span < len(v.spans) && v.spans[span].From <= at - if styled { - style = v.spans[span] - } - if r == '\t' || r < 0x20 { - p.flush(text[labelAt:labelTo], label, labelEnd) - label = -1 - cells += width - continue - } - invalid := r == utf8.RuneError && size == 1 - if label < 0 || invalid || cells+width-label > limit { - p.flush(text[labelAt:labelTo], label, labelEnd) - label, labelAt, labelTo, run = cells, at, at, -1 - } - color, weight := p.style.Color, float32(0) - if styled { - color = p.spanColor(style) - if style.Bold { - weight = gfx.WeightBold - } - } - italic := styled && style.Italic - ascii := r < 0x80 - if ascii && runASCII && run >= 0 && p.runs[run].Color == color && p.runs[run].Weight == weight && - p.runs[run].Italic == italic && p.runs[run].Underline == style.Underline && p.runs[run].Strike == style.Strike { - p.runs[run].Bytes += int32(size) - p.runs[run].Cells += int32(width) - } else { - bytes := size - if invalid { - bytes = len(replacementChar) - } - p.runs = append(p.runs, gfx.TextRun{ - Column: int32(cells - label), Bytes: int32(bytes), Cells: int32(width), - Color: color, Weight: weight, Italic: italic, Underline: style.Underline, Strike: style.Strike, - }) - run, runASCII = len(p.runs)-1, ascii - } - cells += width - labelEnd, labelTo = cells, i - if invalid { - p.flush(replacementChar, label, labelEnd) - label = -1 - } - } - p.flush(text[labelAt:labelTo], label, labelEnd) - return end -} - -// decorate fills the backgrounds of a row's spans and declares the hits of its links with -// the hand cursor, named by their text, under the view's own identity so a press on a link -// still selects. -func (p *painter) decorate(text string, start, end int) { - v := p.v - for _, span := range v.spans { - if span.Background.Alpha <= 0 && !span.Link { - continue - } - a, b := max(span.From, start), min(span.To, end) - if a >= b { - continue - } - x0 := cellsOf(text[start:a], 0) - x1 := x0 + cellsOf(text[a:b], x0) - if p.fit >= 0 { - if x0, x1 = min(x0, p.fit+1), min(x1, p.fit+1); x0 >= x1 { - continue - } - } - rect := gfx.Rect{X: p.left + float32(x0)*v.cellW, Y: p.y, Width: float32(x1-x0) * v.cellW, Height: v.lineH} - if span.Background.Alpha > 0 { - p.canvas.Fill(rect, span.Background) - } - if span.Link { - label := span.Label - if label == "" { - label = text[a:b] - } - p.canvas.HitWithOptions(v.id, rect, label, gfx.HitOptions{Role: gfx.RoleLink, Cursor: gfx.PointerCursorHand}) - } - } -} - -// flush draws the runs gathered for a label from column start to column end and empties -// them for the next label. -func (p *painter) flush(value string, start, end int) { - if len(p.runs) == 0 { - return - } - v := p.v - width := float32(math.Ceil(float64(float32(end-start)*v.cellW))) + 1 - rect := gfx.Rect{X: p.left + float32(start)*v.cellW, Y: p.y + (v.lineH-v.cellH)/2, Width: width, Height: v.cellH} - p.canvas.LabelRuns(value, rect, p.style, v.cellW, p.runs) - p.runs = p.runs[:0] -} diff --git a/desktop/internal/textview/rows.go b/desktop/internal/textview/rows.go deleted file mode 100644 index 5a549f5b9e..0000000000 --- a/desktop/internal/textview/rows.go +++ /dev/null @@ -1,145 +0,0 @@ -package textview - -import ( - "math" - "unicode/utf8" -) - -// layout breaks the lines into rows for a text width, when the view wraps. A view that -// does not wrap has a row for each line and keeps no list of them, so a console of many -// thousands of lines costs nothing to lay out. -func (v *View) layout(width float32) { - src := v.spec.Source - key := layoutKey{revision: v.spec.Revision, width: width, cellW: v.cellW, wrap: v.spec.Wrap} - if src != nil { - key.first, key.count = src.First(), src.Count() - } - if key.revision != 0 && key == v.laid { - return - } - v.laid = key - v.rows = v.rows[:0] - v.wrapCols = 0 - if !v.spec.Wrap || src == nil || v.cellW <= 0 { - return - } - // Two pixels are kept back for the pixel a label is drawn wider (paint.go's flush) and - // its rounding, so a full row stays inside the view. - cols := int((width - 2*v.spec.PadX - 2) / v.cellW) - if cols <= 0 { - // Not painted yet: a row for each line until the width is known. - for n := src.First(); n < src.First()+src.Count(); n++ { - v.rows = append(v.rows, row{line: n, from: 0, to: len(src.Line(n))}) - } - return - } - v.wrapCols = cols - for n := src.First(); n < src.First()+src.Count(); n++ { - v.rows = wrapLine(v.rows, n, src.Line(n), max(cols-v.trailCells(n), 1)) - } -} - -// trailCells is how many cells line n's trail and the gap before it take from the line's -// text, 0 when it has none. -func (v *View) trailCells(n int) int { - if v.spec.Trail == nil || v.canvas == nil || v.cellW <= 0 { - return 0 - } - t := v.spec.Trail(n) - if t.Text == "" { - return 0 - } - return int(math.Ceil(float64((v.canvas.TextWidthStyle(t.Text, t.Style) + trailGap) / v.cellW))) -} - -// wrapLine appends the rows of one line cols columns wide: each ends after the last space -// that fits, or at the column limit when no space does. -func wrapLine(rows []row, n int, text string, cols int) []row { - start, cells, space := 0, 0, -1 - for i := 0; i < len(text); { - r, size := utf8.DecodeRuneInString(text[i:]) - width := runeCells(r, cells) - if cells+width > cols && cells > 0 { - end := i - if space > start { - end = space - } - rows = append(rows, row{line: n, from: start, to: end}) - start, space = end, -1 - cells = cellsOf(text[start:i], 0) - continue - } - cells += width - i += size - if r == ' ' || r == '\t' { - space = i - } - } - return append(rows, row{line: n, from: start, to: len(text)}) -} - -// rowCount is how many rows the text takes. -func (v *View) rowCount() int { - if v.spec.Source == nil { - return 0 - } - if v.spec.Wrap { - return len(v.rows) - } - return v.spec.Source.Count() -} - -// rowBytes is the line row index shows and the bytes of it the row holds. -func (v *View) rowBytes(index int) (line, from, to int) { - if v.spec.Wrap { - r := v.rows[index] - return r.line, r.from, r.to - } - line = v.spec.Source.First() + index - return line, 0, len(v.spec.Source.Line(line)) -} - -// rowLine is the line row index shows. -func (v *View) rowLine(index int) int { - if v.spec.Wrap { - if index >= len(v.rows) { - return v.spec.Source.First() + v.spec.Source.Count() - } - return v.rows[index].line - } - return v.spec.Source.First() + index -} - -// lastRow reports whether row index is the last row of its line. -func (v *View) lastRow(index int) bool { - return !v.spec.Wrap || index+1 >= len(v.rows) || v.rows[index+1].line != v.rows[index].line -} - -// firstRowOf is the index of line n's first row. -func (v *View) firstRowOf(n int) (int, bool) { - src := v.spec.Source - if src == nil || n < src.First() || n >= src.First()+src.Count() { - return 0, false - } - if !v.spec.Wrap { - return n - src.First(), true - } - for i, r := range v.rows { - if r.line == n { - return i, true - } - } - return 0, false -} - -// rowRange is the rows the clip shows, from the first to the one after the last. -func (v *View) rowRange() (int, int) { - count := v.rowCount() - if v.lineH <= 0 || count == 0 { - return 0, 0 - } - top := v.clip.Y - v.rect.Y - v.spec.PadY - from := max(int(math.Floor(float64(top/v.lineH))), 0) - to := min(int(math.Ceil(float64((top+v.clip.Height)/v.lineH))), count) - return min(from, count), max(to, min(from, count)) -} diff --git a/desktop/internal/textview/selection.go b/desktop/internal/textview/selection.go deleted file mode 100644 index 2752776961..0000000000 --- a/desktop/internal/textview/selection.go +++ /dev/null @@ -1,252 +0,0 @@ -// Package textview is read-only text the user can select and copy: the console of a run, -// a build or a test, and the details of a commit. The text is drawn on the fixed-pitch -// grid, every line of it or only the rows in view, and takes the selection a text field -// takes in IntelliJ IDEA: a drag, across lines too, a double click for a word, a triple -// click for a line, Shift with a click to extend it, Primary+C to copy it and Primary+A to -// select everything. It never edits what it shows. -package textview - -import ( - "strings" - "unicode" - "unicode/utf8" -) - -// Point is a place in the text: the number of a line, as the Source numbers it, and a -// byte offset into the line. -type Point struct { - Line, Byte int -} - -// Less reports whether p comes before q. -func (p Point) Less(q Point) bool { - return p.Line < q.Line || p.Line == q.Line && p.Byte < q.Byte -} - -// Source is the lines a view shows. The lines are numbered from First on, and a line -// number stays the line's while the source holds it: a console that drops its oldest -// lines raises First, so a selection made before still names the same text. -type Source interface { - First() int - Count() int - Line(n int) string -} - -// Strings is a Source of lines held in a slice, numbered from 0. -type Strings []string - -func (s Strings) First() int { return 0 } -func (s Strings) Count() int { return len(s) } -func (s Strings) Line(n int) string { return s[n] } - -// unit is what a press selects and a drag extends by: characters after one click, words -// after two and lines after three. -type unit uint8 - -const ( - unitChar unit = iota - unitWord - unitLine -) - -// Selection is the selected range of a view's text. The press that began it fixes the -// anchor, the character, word or line under it, and a drag or a Shift click moves the -// focus; the range runs between them, in whole words or lines for a press of two or -// three clicks. -type Selection struct { - anchorFrom, anchorTo Point - focusFrom, focusTo Point - unit unit - set bool -} - -// Begin starts a selection at a press: an empty one at the nearest character boundary -// after one click, the word under the pointer after two and the line after three. line -// is the text of at.Line. -func (s *Selection) Begin(at Point, line string, clicks int) { - s.unit = unitChar - switch { - case clicks >= 3: - s.unit = unitLine - case clicks == 2: - s.unit = unitWord - } - s.anchorFrom, s.anchorTo = s.span(at, line) - s.focusFrom, s.focusTo = s.anchorFrom, s.anchorTo - s.set = true -} - -// Extend moves the focus to at, by the unit of the press that began the selection. It -// begins a selection of characters when there is none. -func (s *Selection) Extend(at Point, line string) { - if !s.set { - s.Begin(at, line, 1) - return - } - s.focusFrom, s.focusTo = s.span(at, line) -} - -// span is the unit around at: at itself for characters, the word under it or the whole -// line, ending at the start of the next line. -func (s *Selection) span(at Point, line string) (Point, Point) { - at.Byte = boundary(line, at.Byte) - switch s.unit { - case unitWord: - from, to := wordAt(line, at.Byte) - return Point{at.Line, from}, Point{at.Line, to} - case unitLine: - return Point{at.Line, 0}, Point{at.Line + 1, 0} - } - return at, at -} - -// SelectAll selects every line src holds. -func (s *Selection) SelectAll(src Source) { - if src.Count() == 0 { - s.Clear() - return - } - last := src.First() + src.Count() - 1 - s.unit = unitChar - s.anchorFrom, s.anchorTo = Point{src.First(), 0}, Point{src.First(), 0} - s.focusFrom, s.focusTo = Point{last, len(src.Line(last))}, Point{last, len(src.Line(last))} - s.set = true -} - -// Clear drops the selection. -func (s *Selection) Clear() { *s = Selection{} } - -// Lines is the first and the last line the selection's anchor and focus are on, and false -// when there is no selection. A line selected by a triple click ends at the start of the line -// after it, which then is the last. -func (s *Selection) Lines() (int, int, bool) { - if !s.set { - return 0, 0, false - } - return min(s.anchorFrom.Line, s.focusFrom.Line), max(s.anchorTo.Line, s.focusTo.Line), true -} - -// Move renumbers the selection's lines by delta, for a source whose lines moved: the same -// text, now delta lines further on. -func (s *Selection) Move(delta int) { - for _, p := range []*Point{&s.anchorFrom, &s.anchorTo, &s.focusFrom, &s.focusTo} { - p.Line += delta - } -} - -// Range is the selection in src, from its start to its end, clamped to the lines src -// still holds and to character boundaries. ok is false when nothing is selected. -func (s *Selection) Range(src Source) (from, to Point, ok bool) { - if !s.set || src.Count() == 0 { - return Point{}, Point{}, false - } - from, to = s.anchorFrom, s.anchorTo - if s.focusFrom.Less(s.anchorFrom) { - from = s.focusFrom - } - if to.Less(s.focusTo) { - to = s.focusTo - } - from, to = clamp(src, from), clamp(src, to) - if !from.Less(to) { - return Point{}, Point{}, false - } - return from, to, true -} - -// Has reports whether anything is selected in src. -func (s *Selection) Has(src Source) bool { - _, _, ok := s.Range(src) - return ok -} - -// Text is the selected text of src, its lines joined with newlines. -func (s *Selection) Text(src Source) string { - from, to, ok := s.Range(src) - if !ok { - return "" - } - return Text(src, from, to) -} - -// Text is the text of src from one point to another, its lines joined with newlines. -func Text(src Source, from, to Point) string { - if from.Line == to.Line { - return src.Line(from.Line)[from.Byte:to.Byte] - } - var b strings.Builder - b.WriteString(src.Line(from.Line)[from.Byte:]) - for n := from.Line + 1; n < to.Line; n++ { - b.WriteByte('\n') - b.WriteString(src.Line(n)) - } - b.WriteByte('\n') - b.WriteString(src.Line(to.Line)[:to.Byte]) - return b.String() -} - -// clamp moves p into the lines src holds: before them to the start of the first, after -// them to the end of the last, and inside a character to its start. -func clamp(src Source, p Point) Point { - first, last := src.First(), src.First()+src.Count()-1 - switch { - case p.Line < first: - return Point{first, 0} - case p.Line > last: - return Point{last, len(src.Line(last))} - } - return Point{p.Line, boundary(src.Line(p.Line), p.Byte)} -} - -// boundary moves at into text and back to the start of the character it is inside. -func boundary(text string, at int) int { - at = min(max(at, 0), len(text)) - for at > 0 && at < len(text) && !utf8.RuneStart(text[at]) { - at-- - } - return at -} - -// wordAt is the word, the run of spaces or the run of punctuation under the character -// at at, as a double click in IntelliJ IDEA's editor selects it. At the end of the text -// it is the one before. -func wordAt(text string, at int) (int, int) { - if text == "" { - return 0, 0 - } - if at >= len(text) { - _, size := utf8.DecodeLastRuneInString(text) - at = len(text) - size - } - r, _ := utf8.DecodeRuneInString(text[at:]) - class := charClass(r) - from := at - for from > 0 { - r, size := utf8.DecodeLastRuneInString(text[:from]) - if charClass(r) != class { - break - } - from -= size - } - to := at - for to < len(text) { - r, size := utf8.DecodeRuneInString(text[to:]) - if charClass(r) != class { - break - } - to += size - } - return from, to -} - -// charClass sorts characters for wordAt: spaces, the characters of identifiers and -// numbers, and everything else. -func charClass(r rune) int { - switch { - case unicode.IsSpace(r): - return 1 - case r == '_' || unicode.IsLetter(r) || unicode.IsDigit(r): - return 2 - } - return 3 -} diff --git a/desktop/internal/textview/selection_test.go b/desktop/internal/textview/selection_test.go deleted file mode 100644 index b58878da2c..0000000000 --- a/desktop/internal/textview/selection_test.go +++ /dev/null @@ -1,177 +0,0 @@ -package textview - -import ( - "slices" - "testing" -) - -// trimmed is a Source whose oldest lines are gone, as a console's are once it is full: its -// lines are numbered from first on. -type trimmed struct { - first int - lines []string -} - -func (s trimmed) First() int { return s.first } -func (s trimmed) Count() int { return len(s.lines) } -func (s trimmed) Line(n int) string { return s.lines[n-s.first] } - -func TestSelectionRunsBetweenAnchorAndFocusEitherWay(t *testing.T) { - src := Strings{"first line", "second line", "third"} - var s Selection - s.Begin(Point{2, 2}, src[2], 1) - s.Extend(Point{0, 6}, src[0]) - if got, want := s.Text(src), "line\nsecond line\nth"; got != want { - t.Fatalf("a drag back up selected %q, want %q", got, want) - } - s.Begin(Point{1, 3}, src[1], 1) - if s.Has(src) { - t.Fatalf("a press alone selected %q", s.Text(src)) - } -} - -func TestSelectionByWordsAndLinesKeepsTheWholeUnits(t *testing.T) { - src := Strings{"at demo.Main.run(Main.java:12)", "next line"} - var s Selection - s.Begin(Point{0, 5}, src[0], 2) - if got := s.Text(src); got != "demo" { - t.Fatalf("a double click selected %q, want the word", got) - } - // A drag after a double click extends by whole words, both ends kept whole. - s.Extend(Point{0, 15}, src[0]) - if got := s.Text(src); got != "demo.Main.run" { - t.Fatalf("a drag by words selected %q", got) - } - s.Begin(Point{0, 3}, src[0], 3) - if got, want := s.Text(src), src[0]+"\n"; got != want { - t.Fatalf("a triple click selected %q, want the line and its newline", got) - } - // The last line has no newline after it to take. - s.Begin(Point{1, 0}, src[1], 3) - if got := s.Text(src); got != "next line" { - t.Fatalf("a triple click on the last line selected %q", got) - } -} - -func TestSelectAllAndClear(t *testing.T) { - src := Strings{"a", "", "b c"} - var s Selection - s.SelectAll(src) - if got := s.Text(src); got != "a\n\nb c" { - t.Fatalf("Select All selected %q", got) - } - s.Clear() - if s.Has(src) { - t.Fatal("Clear kept a selection") - } - s.SelectAll(Strings{}) - if s.Has(Strings{}) { - t.Fatal("Select All of nothing selected something") - } -} - -// A console that drops its oldest lines keeps what is left of a selection over them. -func TestSelectionKeepsToItsLinesWhenTheOldestGo(t *testing.T) { - src := trimmed{first: 0, lines: []string{"zero", "one", "two", "three"}} - var s Selection - s.Begin(Point{0, 2}, src.Line(0), 1) - s.Extend(Point{2, 2}, src.Line(2)) - src = trimmed{first: 1, lines: src.lines[1:]} - if got, want := s.Text(src), "one\ntw"; got != want { - t.Fatalf("after the first line went the selection is %q, want %q", got, want) - } - src = trimmed{first: 3, lines: src.lines[2:]} - if s.Has(src) { - t.Fatalf("after every selected line went %q is still selected", s.Text(src)) - } -} - -func TestWordAtSortsSpacesWordsAndPunctuation(t *testing.T) { - text := "foo_bar1 (x) 中文" - cases := []struct { - at int - from, to int - }{ - {0, 0, 8}, // foo_bar1 - {8, 8, 10}, // the two spaces - {10, 10, 11}, // ( - {len(text), len("foo_bar1 (x) "), len(text)}, // at the end: the word before - {len("foo_bar1 (x) ") + 3, len("foo_bar1 (x) "), len(text)}, - } - for _, c := range cases { - if from, to := wordAt(text, c.at); from != c.from || to != c.to { - t.Errorf("wordAt(%d) = %d..%d (%q), want %d..%d", c.at, from, to, text[from:to], c.from, c.to) - } - } - if from, to := wordAt("", 0); from != 0 || to != 0 { - t.Errorf("wordAt of nothing = %d..%d", from, to) - } -} - -// A point inside a character, as a byte offset from another line can be, moves to its start. -func TestRangeClampsToCharacterBoundaries(t *testing.T) { - src := Strings{"中文", "abc"} - var s Selection - s.Begin(Point{0, 1}, "abc", 1) // made with the text of another line - s.Extend(Point{1, 2}, src[1]) - if got := s.Text(src); got != "中文\nab" { - t.Fatalf("selected %q, want it to start at the character", got) - } -} - -func TestByteAtPicksTheCellUnderAColumn(t *testing.T) { - text := "a\tb中c" - // a: column 0; tab: 1..4; b: 4; 中: 5..7; c: 7. - cases := []struct { - column float32 - nearest bool - want int - }{ - {0.2, true, 0}, - {0.6, true, 1}, - {0.6, false, 0}, - {2, false, 1}, - {4.2, false, 2}, - {5.2, true, 3}, - {6.5, true, 6}, - {6.5, false, 3}, - {7.1, false, 6}, - {40, true, len(text)}, - } - for _, c := range cases { - if got := byteAt(text, c.column, c.nearest); got != c.want { - t.Errorf("byteAt(%v, nearest %v) = %d, want %d", c.column, c.nearest, got, c.want) - } - } -} - -func TestWrapLineBreaksAfterASpaceOrAtTheLimit(t *testing.T) { - rows := wrapLine(nil, 0, "alpha beta gamma", 11) - got := make([]string, 0, len(rows)) - for _, r := range rows { - got = append(got, "alpha beta gamma"[r.from:r.to]) - } - if want := []string{"alpha beta ", "gamma"}; !slices.Equal(got, want) { - t.Fatalf("rows %q, want %q", got, want) - } - long := "" - rows = wrapLine(nil, 3, long, 10) - joined := "" - for _, r := range rows { - if r.line != 3 || cellsOf(long[r.from:r.to], 0) > 10 { - t.Fatalf("row %+v of %q is wider than the limit or of another line", r, long) - } - joined += long[r.from:r.to] - } - if joined != long || len(rows) < 4 { - t.Fatalf("the rows of a word wider than a line join to %q in %d rows", joined, len(rows)) - } - // A wide character that does not fit moves to the next row whole. - rows = wrapLine(nil, 0, "abc中", 4) - if len(rows) != 2 || rows[0].to != 3 { - t.Fatalf("rows %+v, want the wide character on a row of its own", rows) - } - if rows := wrapLine(nil, 0, "", 4); len(rows) != 1 || rows[0].from != 0 || rows[0].to != 0 { - t.Fatalf("an empty line has rows %+v, want one empty row", rows) - } -} diff --git a/desktop/internal/textview/view.go b/desktop/internal/textview/view.go deleted file mode 100644 index b665e6994a..0000000000 --- a/desktop/internal/textview/view.go +++ /dev/null @@ -1,541 +0,0 @@ -package textview - -import ( - "math" - "time" - - "github.com/vivaui/viva/app" - "github.com/vivaui/viva/gfx" - "github.com/vivaui/viva/ui" -) - -// Span is a styled byte range of one line: its color, an optional background, and -// whether it is a link a click opens. -type Span struct { - From, To int - Color gfx.Color - Background gfx.Color // drawn when its Alpha is above zero - Bold bool - Italic bool - Underline bool - Strike bool - Link bool - // Hover is the color of a link while the pointer is over it, when its Alpha is above - // zero. Label names the link for assistive technology; empty names it by its text. - Hover gfx.Color - Label string -} - -// Trail is a note drawn after a line, at the view's right edge on the line's first row: a -// badge, or with Button set a button a click presses. It is not part of the text, so a -// selection never takes it and a copy never holds it. -type Trail struct { - Text string - Style gfx.TextStyle - Button bool -} - -// trailGap is the room between a line's text and its trail. -const trailGap = 6 - -// ellipsis ends a line cut short; it takes one cell. -const ellipsis = "\u2026" - -// Spec is what a view shows and how, given again in every paint. -type Spec struct { - // Label names the text for assistive technology. - Label string - Source Source - // Font is the fixed-pitch face and size the text is drawn in; its Color is the color - // of what no span colors. LineHeight is the height of one row. - Font gfx.TextStyle - LineHeight float32 - PadX, PadY float32 - // Selection is the color behind the selected text. - Selection gfx.Color - // Scroll makes the view an area of its own that scrolls, keeps to the newest line - // while the user has not scrolled up (Follow) and fills the area's height. Without it - // the view is as tall as its text, to be placed in a scrolling area. - Scroll bool - Follow bool - // Wrap breaks a line wider than the view into rows, at a space where it can. - Wrap bool - // Ellipsis cuts a line wider than a view that does not wrap one cell short of the edge, - // and ends it in an ellipsis in the color it was cut in. The text cut off is still - // selected and copied. - Ellipsis bool - // Revision, when not zero, changes whenever the lines or their trails do, so a view - // that wraps breaks its lines again only when it or the width changed. Zero breaks them - // on every paint. - Revision uint64 - // LineBackground is the color behind line n, across the view, when its Alpha is above - // zero. - LineBackground func(n int) gfx.Color - // Trail is the note drawn after line n; one with no Text draws nothing. PressTrail is - // called with n when a click without a drag lands on a Button trail. - Trail func(n int) Trail - PressTrail func(n int) - // Spans styles line n, whose text is text, appending to dst. Nil draws every line in - // Font. It is asked only for the rows on screen and for the line a click lands on. - Spans func(n int, text string, dst []Span) []Span - // Open is called with a link span a click without a drag landed on. - Open func(n int, span Span) - // Copy puts the selection Primary+C copies on the clipboard; nil puts it there as it - // is. - Copy func(text string) - // Menu, when set, is the context menu a secondary press opens. - Menu func(*ui.MenuItems) -} - -// View is the state of one read-only text: its selection, the press being followed and -// where the last paint put its rows. Keep it in the model with what it shows. -type View struct { - Selection Selection - - spec Spec - input ui.Handlers - draw func(*ui.DrawContext) - id gfx.ID - - // rect is the control as the last paint placed it and clip the part of it on screen; - // cellW and lineH are the grid it was drawn on, width the text width it wrapped at, - // and rows its rows when it wraps. - rect, clip gfx.Rect - cellW, cellH float32 - lineH float32 - width float32 - rows []row - wrapCols int - - // pressed says a primary press on the view is held; press is where it went down and - // moved whether it has left that spot, and pointer where the pointer is now. - pressed bool - moved bool - press gfx.Point - pointer gfx.Point - clicks int - // stepAt is when the drag past an edge last scrolled the area. - stepAt time.Duration - - menuOpen bool - menuAt gfx.Point - menuLine int - menuSet bool - - toEnd bool - // scrollLine, when scrollSet, is the line the next paint of a scrolling view centers. - scrollLine int - scrollSet bool - spans []Span - // wrap lays out a view that wraps and does not scroll, at the width the page gives it. - wrap wrapLayout - // canvas is the canvas of the last declaration, which measures the trails. - canvas *gfx.Canvas - // laid is what the rows were broken for. - laid layoutKey - - // trails are the Button trails the last paint drew; trailHeld says a press went down on - // the trail of line trailLine. - trails []trailHit - trailHeld bool - trailLine int - // hover is the link under the pointer, when hovering: its line and its first byte. - hover Point - hovering bool -} - -// trailHit is where a paint drew the Button trail of a line. -type trailHit struct { - line int - rect gfx.Rect -} - -// layoutKey is what a wrapped view's rows depend on. -type layoutKey struct { - revision uint64 - width, cellW float32 - first, count int - wrap bool -} - -// row is one row of a wrapped view: the bytes from to to of line. -type row struct { - line, from, to int -} - -// ScrollToEnd keeps a scrolling view at its newest line from the next paint on. -func (v *View) ScrollToEnd() { v.toEnd, v.scrollSet = true, false } - -// ScrollTo scrolls a scrolling view in its next paint so that line n is in the middle of -// it, and stops it following the newest line. -func (v *View) ScrollTo(n int) { v.scrollLine, v.scrollSet, v.toEnd = n, true, false } - -// MenuLine is the line a secondary press opened the menu on, and false when it was below -// the text. -func (v *View) MenuLine() (int, bool) { return v.menuLine, v.menuSet } - -// Has reports whether text is selected. -func (v *View) Has() bool { return v.spec.Source != nil && v.Selection.Has(v.spec.Source) } - -// Text is the selected text. -func (v *View) Text() string { - if v.spec.Source == nil { - return "" - } - return v.Selection.Text(v.spec.Source) -} - -// SelectAll selects all the text. -func (v *View) SelectAll() { - if v.spec.Source != nil { - v.Selection.SelectAll(v.spec.Source) - } -} - -// RowRect is where the last paint put line n's first row, and false when that row was -// not on screen. -func (v *View) RowRect(n int) (gfx.Rect, bool) { - index, ok := v.firstRowOf(n) - if !ok { - return gfx.Rect{}, false - } - r := gfx.Rect{X: v.rect.X, Y: v.rect.Y + v.spec.PadY + float32(index)*v.lineH, Width: v.rect.Width, Height: v.lineH} - if r.Y+r.Height <= v.clip.Y || r.Y >= v.clip.Y+v.clip.Height { - return gfx.Rect{}, false - } - return r, true -} - -// PointOf is a point in the first quarter of the cell the last paint put byte p.Byte of -// line p.Line in, where a click places the caret before that character and a double click -// picks the word it is in; false when its row was not on screen. -func (v *View) PointOf(p Point) (gfx.Point, bool) { - src := v.spec.Source - index, ok := v.firstRowOf(p.Line) - if !ok { - return gfx.Point{}, false - } - for index+1 < v.rowCount() && !v.lastRow(index) { - if _, _, to := v.rowBytes(index); p.Byte < to { - break - } - index++ - } - _, from, _ := v.rowBytes(index) - text := src.Line(p.Line) - at := min(max(p.Byte, from), len(text)) - x := v.rect.X + v.spec.PadX + (float32(cellsOf(text[from:at], 0))+0.25)*v.cellW - y := v.rect.Y + v.spec.PadY + (float32(index)+0.5)*v.lineH - if y < v.clip.Y || y >= v.clip.Y+v.clip.Height { - return gfx.Point{}, false - } - return gfx.Point{X: x, Y: y}, true -} - -// Visible is the range of lines the last paint showed, from the first to the one after -// the last. -func (v *View) Visible() (int, int) { - src := v.spec.Source - if src == nil || v.lineH <= 0 { - return 0, 0 - } - from, to := v.rowRange() - return v.rowLine(from), v.rowLine(max(to-1, from)) + 1 -} - -// Declare declares the view with spec and returns its outermost box: the scrolling area, -// or the text itself. -func (v *View) Declare(c ui.C, spec Spec) ui.Box { - v.spec = spec - if v.draw == nil { - v.draw = v.paint - v.input = ui.Handlers{Role: gfx.RoleGroup, Pointer: v.onPointer, Key: v.onKey} - } - canvas := c.Canvas() - v.canvas = canvas - v.cellW, v.cellH = canvas.MonoCellSize(spec.Font.Size, spec.Font.MonoFace) - v.lineH = max(spec.LineHeight, v.cellH) - v.layout(v.width) - height := float32(v.rowCount())*v.lineH + 2*spec.PadY - var control, outer ui.Box - if spec.Scroll { - outer = ui.Scroll(c).Scrollbars().Follow(spec.Follow).Label(spec.Label) - state := outer.ScrollState() - if v.toEnd { - v.toEnd = false - state.ScrollToEnd() - } - v.dragScroll(canvas, state) - if v.scrollSet { - v.scrollSet = false - if index, ok := v.firstRowOf(v.scrollLine); ok { - // The area knows the new height only once it lays it out; it is told now, so - // the offset is not clamped to the old one and the area stops following. - state.Content = max(state.Content, height) - target := spec.PadY + float32(index)*v.lineH - (state.Viewport-v.lineH)/2 - state.ScrollTo(min(max(target, 0), max(state.Content-state.Viewport, 0))) - } - } - height = max(height, state.Viewport) - outer.Children(func() { - v.id = ui.ID(c.Part("text")) - control = ui.Control(c.Part("text"), spec.Label, &v.input).FillWidth().Height(height).Draw(v.draw) - }) - } else if spec.Wrap { - // The rows depend on the width, which the page knows only once it lays the view - // out: the layout wraps the lines there, before it asks for the height. - v.wrap.v = v - outer = ui.CustomLayout(c, &v.wrap).FillWidth().Children(func() { - v.id = ui.ID(c.Part("text")) - control = ui.Control(c.Part("text"), spec.Label, &v.input).Draw(v.draw) - }) - } else { - v.id = ui.ID(c.Part("text")) - control = ui.Control(c.Part("text"), spec.Label, &v.input).FillWidth().Height(height).Draw(v.draw) - outer = control - } - if control.Shortcut(ui.Primary, "c") && v.Has() { - text, copy := v.Text(), spec.Copy - c.After(func() { - if copy != nil { - copy(text) - return - } - _ = app.SetClipboardText(text) - }) - } - if control.Shortcut(ui.Primary, "a") { - v.SelectAll() - } - if spec.Menu != nil { - ui.ContextMenuAt(c.Key("menu"), control, &v.menuOpen, v.menuAt, spec.Menu) - } - return outer -} - -// wrapLayout lays out a view that wraps: the text takes the width it is given and is as -// tall as its rows at that width. -type wrapLayout struct{ v *View } - -func (l *wrapLayout) MeasureWidth(*ui.LayoutContext) float32 { return 0 } - -func (l *wrapLayout) PlaceWidth(ctx *ui.LayoutContext, bounds ui.Rect) { - if v := l.v; bounds.Width != v.width { - v.width = bounds.Width - v.layout(v.width) - } - if ctx.Count() > 0 { - ctx.SetX(0, bounds.X) - ctx.SetWidth(0, bounds.Width) - } -} - -func (l *wrapLayout) MeasureHeight(*ui.LayoutContext) float32 { - v := l.v - return float32(v.rowCount())*v.lineH + 2*v.spec.PadY -} - -func (l *wrapLayout) PlaceHeight(ctx *ui.LayoutContext, bounds ui.Rect) { - if ctx.Count() > 0 { - ctx.SetY(0, bounds.Y) - ctx.SetHeight(0, bounds.Height) - } -} - -// dragScroll scrolls the area while a drag holds the pointer past its top or bottom edge, -// a step of rows every 50 ms that grows with the distance, as IDEA's editor does. -func (v *View) dragScroll(canvas *gfx.Canvas, state *ui.ScrollState) { - if !v.pressed || !v.moved || v.lineH <= 0 { - return - } - top, bottom := v.clip.Y, v.clip.Y+v.clip.Height - distance := float32(0) - switch { - case v.pointer.Y < top: - distance = v.pointer.Y - top - case v.pointer.Y > bottom: - distance = v.pointer.Y - bottom - default: - return - } - now := canvas.Now() - if now-v.stepAt >= dragStep { - v.stepAt = now - lines := min(1+float32(math.Abs(float64(distance)))/v.lineH, 8) - if distance < 0 { - lines = -lines - } - state.ScrollTo(min(max(state.Offset+float32(int(lines))*v.lineH, 0), state.Max())) - } - canvas.RequestFrameIn(dragStep) -} - -const dragStep = 50 * time.Millisecond - -// onPointer selects with the primary button, opens a link a click lands on and opens -// the menu at a secondary press. -func (v *View) onPointer(event gfx.PointerEvent) gfx.EventResult { - src := v.spec.Source - if src == nil { - return gfx.EventResult{} - } - at := gfx.Point{X: event.X, Y: event.Y} - switch event.Kind { - case gfx.PointerDown: - if event.Button == gfx.PointerButtonSecondary { - if v.spec.Menu == nil { - return gfx.EventResult{} - } - v.menuLine, v.menuSet = 0, false - if p, ok := v.pointAt(at, false); ok { - v.menuLine, v.menuSet = p.Line, true - } - v.menuOpen, v.menuAt = true, at - return gfx.EventResult{Handled: true, Repaint: true} - } - if event.Button != gfx.PointerButtonPrimary { - return gfx.EventResult{} - } - if n, ok := v.trailAt(at); ok { - // A press on a button after a line presses it, and leaves the selection be. - v.trailHeld, v.trailLine = true, n - return gfx.EventResult{Handled: true} - } - v.pressed, v.moved, v.press, v.pointer, v.clicks = true, false, at, at, max(event.ClickCount, 1) - p, ok := v.pointAt(at, v.clicks == 1) - if !ok { - v.Selection.Clear() - return gfx.EventResult{Handled: true, Repaint: true} - } - if event.Modifiers&gfx.ModifierShift != 0 && v.clicks == 1 { - v.Selection.Extend(p, src.Line(p.Line)) - v.moved = true - } else { - v.Selection.Begin(p, src.Line(p.Line), v.clicks) - } - return gfx.EventResult{Handled: true, Repaint: true} - case gfx.PointerMove: - if !v.pressed { - return gfx.EventResult{Handled: v.trailHeld, Repaint: v.hoverAt(at)} - } - v.pointer = at - if !v.moved && math.Abs(float64(at.X-v.press.X)) < 3 && math.Abs(float64(at.Y-v.press.Y)) < 3 { - return gfx.EventResult{Handled: true} - } - v.moved = true - v.extendTo(at) - return gfx.EventResult{Handled: true, Repaint: true} - case gfx.PointerUp: - if v.trailHeld { - v.trailHeld = false - if n, ok := v.trailAt(at); ok && n == v.trailLine && v.spec.PressTrail != nil { - v.spec.PressTrail(n) - } - return gfx.EventResult{Handled: true, Repaint: true} - } - if !v.pressed { - return gfx.EventResult{} - } - v.pressed = false - if !v.moved && v.clicks == 1 && v.spec.Open != nil { - if n, span, ok := v.linkAt(at); ok { - v.spec.Open(n, span) - } - } - return gfx.EventResult{Handled: true, Repaint: true} - case gfx.PointerExit: - if v.hovering { - v.hovering = false - return gfx.EventResult{Repaint: true} - } - return gfx.EventResult{} - } - return gfx.EventResult{} -} - -// trailAt is the line whose Button trail the last paint drew under a point. -func (v *View) trailAt(at gfx.Point) (int, bool) { - for _, t := range v.trails { - if r := t.rect; at.X >= r.X && at.X < r.X+r.Width && at.Y >= r.Y && at.Y < r.Y+r.Height { - return t.line, true - } - } - return 0, false -} - -// hoverAt follows the link under the pointer, for a link with a Hover color, and reports -// whether it changed. -func (v *View) hoverAt(at gfx.Point) bool { - n, span, ok := v.linkAt(at) - ok = ok && span.Hover.Alpha > 0 - p := Point{n, span.From} - if ok == v.hovering && (!ok || p == v.hover) { - return false - } - v.hover, v.hovering = p, ok - return true -} - -// extendTo moves the selection's focus to the point under the pointer, clamped into the -// text. -func (v *View) extendTo(at gfx.Point) { - src := v.spec.Source - if src.Count() == 0 { - return - } - if p, ok := v.pointAt(at, v.Selection.unit == unitChar); ok { - v.Selection.Extend(p, src.Line(p.Line)) - } -} - -// onKey clears the selection with Escape. -func (v *View) onKey(event gfx.KeyEvent) gfx.EventResult { - if event.Release || event.Key != gfx.KeyEscape || v.spec.Source == nil || !v.Has() { - return gfx.EventResult{} - } - v.Selection.Clear() - return gfx.EventResult{Handled: true, Repaint: true} -} - -// linkAt is the link span under a point. -func (v *View) linkAt(at gfx.Point) (int, Span, bool) { - p, ok := v.pointAt(at, false) - if !ok || v.spec.Spans == nil { - return 0, Span{}, false - } - text := v.spec.Source.Line(p.Line) - if p.Byte >= len(text) { - return 0, Span{}, false - } - v.spans = v.spec.Spans(p.Line, text, v.spans[:0]) - for _, span := range v.spans { - if span.Link && span.From <= p.Byte && p.Byte < span.To { - return p.Line, span, true - } - } - return 0, Span{}, false -} - -// pointAt is the place in the text under a point of the window, clamped into the text: -// a point above it is its start and one below its end. nearest picks the closest -// character boundary rather than the character under the point. ok is false for a view -// with no text. -func (v *View) pointAt(at gfx.Point, nearest bool) (Point, bool) { - src := v.spec.Source - count := v.rowCount() - if src == nil || src.Count() == 0 || count == 0 || v.lineH <= 0 || v.cellW <= 0 { - return Point{}, false - } - index := int(math.Floor(float64((at.Y - v.rect.Y - v.spec.PadY) / v.lineH))) - if index < 0 { - return Point{src.First(), 0}, true - } - if index >= count { - last := src.First() + src.Count() - 1 - return Point{last, len(src.Line(last))}, true - } - line, from, to := v.rowBytes(index) - text := src.Line(line) - column := (at.X - v.rect.X - v.spec.PadX) / v.cellW - return Point{line, from + byteAt(text[from:to], column, nearest)}, true -} diff --git a/desktop/internal/workbench/console_selection_test.go b/desktop/internal/workbench/console_selection_test.go index 7813fff413..20b6dfaa47 100644 --- a/desktop/internal/workbench/console_selection_test.go +++ b/desktop/internal/workbench/console_selection_test.go @@ -4,8 +4,8 @@ import ( "testing" "github.com/1lck/Lithe-IDEA/desktop/internal/core" - "github.com/1lck/Lithe-IDEA/desktop/internal/textview" "github.com/vivaui/viva/gfx" + "github.com/vivaui/viva/ui/textview" ) // showRunConsole shows a run whose console holds text, in the Run window. diff --git a/desktop/internal/workbench/gitconsole.go b/desktop/internal/workbench/gitconsole.go index 0b062a9cd8..bb1526f222 100644 --- a/desktop/internal/workbench/gitconsole.go +++ b/desktop/internal/workbench/gitconsole.go @@ -11,10 +11,10 @@ import ( "github.com/1lck/Lithe-IDEA/desktop/internal/core" "github.com/1lck/Lithe-IDEA/desktop/internal/i18n" - "github.com/1lck/Lithe-IDEA/desktop/internal/textview" "github.com/vivaui/viva/app" vivatext "github.com/vivaui/viva/text" "github.com/vivaui/viva/ui" + "github.com/vivaui/viva/ui/textview" ) // The Console tab of the Git tool window lists the Git commands every project of the window diff --git a/desktop/internal/workbench/gitconsole_test.go b/desktop/internal/workbench/gitconsole_test.go index 53f6f371df..0025750977 100644 --- a/desktop/internal/workbench/gitconsole_test.go +++ b/desktop/internal/workbench/gitconsole_test.go @@ -10,7 +10,7 @@ import ( "github.com/1lck/Lithe-IDEA/desktop/internal/core" "github.com/1lck/Lithe-IDEA/desktop/internal/i18n" - "github.com/1lck/Lithe-IDEA/desktop/internal/textview" + "github.com/vivaui/viva/ui/textview" ) // openConsole opens dir, runs a Git command the console records, and shows the Console tab diff --git a/desktop/internal/workbench/gitconsole_view.go b/desktop/internal/workbench/gitconsole_view.go index a0d9979572..4f87586d3f 100644 --- a/desktop/internal/workbench/gitconsole_view.go +++ b/desktop/internal/workbench/gitconsole_view.go @@ -4,9 +4,9 @@ import ( "github.com/1lck/Lithe-IDEA/desktop/internal/core" "github.com/1lck/Lithe-IDEA/desktop/internal/i18n" "github.com/1lck/Lithe-IDEA/desktop/internal/icons" - "github.com/1lck/Lithe-IDEA/desktop/internal/textview" "github.com/vivaui/viva/gfx" "github.com/vivaui/viva/ui" + "github.com/vivaui/viva/ui/textview" ) // The Console tab is one Page: the toolbar with the search over the rows that gitconsole.go diff --git a/desktop/internal/workbench/gitlog_details_test.go b/desktop/internal/workbench/gitlog_details_test.go index 9bbb4cf636..a937401aa0 100644 --- a/desktop/internal/workbench/gitlog_details_test.go +++ b/desktop/internal/workbench/gitlog_details_test.go @@ -6,9 +6,9 @@ import ( "testing" "github.com/1lck/Lithe-IDEA/desktop/internal/core" - "github.com/1lck/Lithe-IDEA/desktop/internal/textview" "github.com/vivaui/viva/app" "github.com/vivaui/viva/gfx" + "github.com/vivaui/viva/ui/textview" ) // TestLogCommitDetailsShowWholeAuthorLine checks that the author line of the commit details diff --git a/desktop/internal/workbench/gitlog_details_view.go b/desktop/internal/workbench/gitlog_details_view.go index 60eb3cb852..4d241fdd7a 100644 --- a/desktop/internal/workbench/gitlog_details_view.go +++ b/desktop/internal/workbench/gitlog_details_view.go @@ -10,11 +10,11 @@ import ( "github.com/1lck/Lithe-IDEA/desktop/internal/fileicons" "github.com/1lck/Lithe-IDEA/desktop/internal/i18n" "github.com/1lck/Lithe-IDEA/desktop/internal/icons" - "github.com/1lck/Lithe-IDEA/desktop/internal/textview" "github.com/1lck/Lithe-IDEA/desktop/internal/treelist" "github.com/vivaui/viva/app" "github.com/vivaui/viva/gfx" "github.com/vivaui/viva/ui" + "github.com/vivaui/viva/ui/textview" ) // This file declares the details pane of the log tab: the files the selected commit changed, diff --git a/desktop/internal/workbench/gitlog_page.go b/desktop/internal/workbench/gitlog_page.go index 8314c19e5b..7c335cb75b 100644 --- a/desktop/internal/workbench/gitlog_page.go +++ b/desktop/internal/workbench/gitlog_page.go @@ -2,9 +2,9 @@ package workbench import ( "github.com/1lck/Lithe-IDEA/desktop/internal/core" - "github.com/1lck/Lithe-IDEA/desktop/internal/textview" "github.com/vivaui/viva/gfx" "github.com/vivaui/viva/ui" + "github.com/vivaui/viva/ui/textview" ) // The identities of the log page's fields, named in the page's own scope so that the diff --git a/desktop/internal/workbench/outputlinks_view.go b/desktop/internal/workbench/outputlinks_view.go index 5018faf80d..8034fc4da6 100644 --- a/desktop/internal/workbench/outputlinks_view.go +++ b/desktop/internal/workbench/outputlinks_view.go @@ -7,10 +7,10 @@ import ( "github.com/1lck/Lithe-IDEA/desktop/internal/core" "github.com/1lck/Lithe-IDEA/desktop/internal/i18n" "github.com/1lck/Lithe-IDEA/desktop/internal/term" - "github.com/1lck/Lithe-IDEA/desktop/internal/textview" "github.com/vivaui/viva/app" "github.com/vivaui/viva/gfx" "github.com/vivaui/viva/ui" + "github.com/vivaui/viva/ui/textview" ) // outputMenu is the context menu of a console's lines, as the old client's output view had: diff --git a/desktop/internal/workbench/readonly_text_selection_visual_test.go b/desktop/internal/workbench/readonly_text_selection_visual_test.go index e2c34bfd47..e8a84e7f7f 100644 --- a/desktop/internal/workbench/readonly_text_selection_visual_test.go +++ b/desktop/internal/workbench/readonly_text_selection_visual_test.go @@ -9,9 +9,9 @@ import ( "github.com/1lck/Lithe-IDEA/desktop/internal/core" "github.com/1lck/Lithe-IDEA/desktop/internal/store" - "github.com/1lck/Lithe-IDEA/desktop/internal/textview" "github.com/vivaui/viva/app" "github.com/vivaui/viva/headless" + "github.com/vivaui/viva/ui/textview" ) // TestVisualReadOnlyTextSelection captures the read-only text the user selects and copies diff --git a/desktop/internal/workbench/runpanels.go b/desktop/internal/workbench/runpanels.go index d0dce15fe2..66e6ff1cd8 100644 --- a/desktop/internal/workbench/runpanels.go +++ b/desktop/internal/workbench/runpanels.go @@ -1,8 +1,8 @@ package workbench import ( - "github.com/1lck/Lithe-IDEA/desktop/internal/textview" "github.com/vivaui/viva/ui" + "github.com/vivaui/viva/ui/textview" ) // runPanels is the view state of the Run, Tests and Debug tool windows of one project. The diff --git a/desktop/internal/workbench/runs.go b/desktop/internal/workbench/runs.go index 1fe8cf2eeb..90be47d9bf 100644 --- a/desktop/internal/workbench/runs.go +++ b/desktop/internal/workbench/runs.go @@ -13,8 +13,8 @@ import ( "github.com/1lck/Lithe-IDEA/desktop/internal/editorview" "github.com/1lck/Lithe-IDEA/desktop/internal/pluginbackend" "github.com/1lck/Lithe-IDEA/desktop/internal/pluginservice" - "github.com/1lck/Lithe-IDEA/desktop/internal/textview" "github.com/1lck/Lithe-IDEA/desktop/internal/toolchain" + "github.com/vivaui/viva/ui/textview" ) const ( diff --git a/desktop/viva.toml b/desktop/viva.toml index 2904529331..f7532ccf5e 100644 --- a/desktop/viva.toml +++ b/desktop/viva.toml @@ -9,7 +9,7 @@ name = "Lithe Desktop" # A separate identity from the SwiftUI client (app.lithe.desktop), so both can be installed # while this client grows. id = "app.lithe.viva" -version = "0.8.4" +version = "0.8.5" executable = "lithe" package = "./cmd/lithe" # The full-bleed square of the SwiftUI client's icon; viva package shapes it into the macOS tile. diff --git a/docs/releases/v0.8.5.md b/docs/releases/v0.8.5.md new file mode 100644 index 0000000000..eae367b2e1 --- /dev/null +++ b/docs/releases/v0.8.5.md @@ -0,0 +1,141 @@ +## 中文 + +Lithe Desktop 0.8.5 让运行更顺手:不装插件也能运行脚本和程序,多个运行可以同时进行,运行前可以先跑其他配置,还能直接运行当前打开的 Java 类。多仓库项目新增共同分支操作。本版为正式版本。 + +### 下载 + +- [项目主页](https://github.com/1lck/Lithe-IDEA) +- [全部下载文件与 SHA-256 校验文件](https://github.com/1lck/Lithe-IDEA/releases/tag/desktop-v0.8.5) + +| 系统与芯片 | 下载格式 | +| --- | --- | +| macOS Apple Silicon | [DMG](https://github.com/1lck/Lithe-IDEA/releases/download/desktop-v0.8.5/lithe-0.8.5-darwin-arm64.dmg) · [ZIP](https://github.com/1lck/Lithe-IDEA/releases/download/desktop-v0.8.5/lithe-0.8.5-darwin-arm64.zip) | +| macOS Intel | [DMG](https://github.com/1lck/Lithe-IDEA/releases/download/desktop-v0.8.5/lithe-0.8.5-darwin-amd64.dmg) · [ZIP](https://github.com/1lck/Lithe-IDEA/releases/download/desktop-v0.8.5/lithe-0.8.5-darwin-amd64.zip) | +| Windows x64 | [安装程序](https://github.com/1lck/Lithe-IDEA/releases/download/desktop-v0.8.5/lithe-0.8.5-windows-amd64-setup.exe) · [ZIP](https://github.com/1lck/Lithe-IDEA/releases/download/desktop-v0.8.5/lithe-0.8.5-windows-amd64.zip) | +| Linux x64 | [DEB](https://github.com/1lck/Lithe-IDEA/releases/download/desktop-v0.8.5/lithe_0.8.5_amd64.deb) · [RPM](https://github.com/1lck/Lithe-IDEA/releases/download/desktop-v0.8.5/lithe-0.8.5-1.x86_64.rpm) · [tar.gz](https://github.com/1lck/Lithe-IDEA/releases/download/desktop-v0.8.5/lithe-0.8.5-linux-amd64.tar.gz) | +| Linux ARM64 | [DEB](https://github.com/1lck/Lithe-IDEA/releases/download/desktop-v0.8.5/lithe_0.8.5_arm64.deb) · [RPM](https://github.com/1lck/Lithe-IDEA/releases/download/desktop-v0.8.5/lithe-0.8.5-1.aarch64.rpm) · [tar.gz](https://github.com/1lck/Lithe-IDEA/releases/download/desktop-v0.8.5/lithe-0.8.5-linux-arm64.tar.gz) | + +### 重点更新 + +本次重点是运行配置和多仓库 Git。 + +#### ✨ 新功能 + +- 不装插件也能创建并运行 Shell、PowerShell、cmd 脚本和可执行程序的运行配置。 +- 多个运行配置可以同时运行,每个都有自己的控制台。 +- 运行配置可以设置启动前步骤,先按顺序运行其他配置,全部成功后再启动。 +- 打开带 main 方法的 Java 类,选“当前文件”点运行即可运行,并自动保存为运行配置。 +- 多仓库文件夹的分支弹窗列出共同分支,可在所有仓库一起检出或新建分支。 +- 多仓库检出只在部分仓库成功时,可以一键回滚已完成的仓库。 + +#### ⚡ 改进 + +- 控制台里的网址可以点击,在浏览器中打开。 +- 运行中的配置在列表和标签上显示运行图标,不再闪动。 +- 多仓库合并日志中,每个仓库当前所在的分支都会高亮。 +- 侧栏的“…”按钮可以像其他按钮一样拖动和移动,移除没有功能的“更新”入口。 +- Windows 上拖动调整窗口大小时界面保持流畅,内容不再被拉伸。 + +#### 🛠 修复 + +- 编辑器和行号栏右键菜单的第一项可以正常点击。 +- Linux Wayland 下点击界面内容后,键盘和输入法不再失灵。 + +### 升级说明 + +- 已安装 0.8.4:在标题栏的更新入口或“设置 → 更新”中检查更新,即可在应用内更新到本版;更早的版本会下载完整安装包。 +- Windows 0.8.0 无法在应用内完成更新,请下载本版安装程序手动安装。 +- macOS:也可选择对应芯片的 DMG,将 `Lithe Desktop.app` 拖入“应用程序”。 +- Homebrew:配方更新到本版后,运行 `brew update && brew upgrade --cask lithe`。 +- Windows:运行 x64 安装程序,或将 ZIP 解压到独立目录后运行 `lithe.exe`。 +- Linux:使用对应架构的 DEB/RPM;tar.gz 用户需要自行满足运行库要求。 + +### 兼容性与已知问题 + +- 运行配置改存为 `.lithe/run/` 下的 YAML 文件,旧的 JSON 在第一次编辑时自动转换;转换后 0.8.4 及更早版本读不到这些配置。 +- 运行当前文件里的 Java 类需要 Maven 插件 1.0.1 及以上;该版插件需要本版或更新的桌面端。 +- macOS 最低为 13.0,分别提供 Apple Silicon 和 Intel 包;Windows 桌面端提供 x64 包。 +- Linux 提供 x64 和 ARM64 包,需要兼容的运行库和图形环境,未验证所有发行版。 +- 自动生成运行配置、调试服务、隐藏 `target`、`node_modules` 等目录需要启用对应的语言或构建插件。 +- 新客户端的功能迁移仍在进行,部分旧版功能尚未完全对齐。 +- macOS 使用临时签名且未公证,Windows 安装包没有发行者签名,系统可能显示安全提示。 + +如果 macOS 提示无法打开 `Lithe Desktop.app`,请在“应用程序”中按住 Control 点按应用并选择“打开”;如果仍被阻止,可执行 `xattr -dr com.apple.quarantine "/Applications/Lithe Desktop.app"`。旧版 `Lithe.app` 对应命令是 `xattr -dr com.apple.quarantine /Applications/Lithe.app`。仅对可信来源的应用使用。 + +[查看完整变更](https://github.com/1lck/Lithe-IDEA/compare/desktop-v0.8.4...desktop-v0.8.5) + +--- + +## English + +Lithe Desktop 0.8.5 makes running easier: run scripts and programs without a plugin, run several configurations at once, run other configurations before launch, and run the Java class you have open. Multi-repository projects gain common branch actions. This is a stable release. + +### Downloads + +- [Project homepage](https://github.com/1lck/Lithe-IDEA) +- [All downloads and SHA-256 checksums](https://github.com/1lck/Lithe-IDEA/releases/tag/desktop-v0.8.5) + +| System and processor | Formats | +| --- | --- | +| macOS Apple Silicon | [DMG](https://github.com/1lck/Lithe-IDEA/releases/download/desktop-v0.8.5/lithe-0.8.5-darwin-arm64.dmg) · [ZIP](https://github.com/1lck/Lithe-IDEA/releases/download/desktop-v0.8.5/lithe-0.8.5-darwin-arm64.zip) | +| macOS Intel | [DMG](https://github.com/1lck/Lithe-IDEA/releases/download/desktop-v0.8.5/lithe-0.8.5-darwin-amd64.dmg) · [ZIP](https://github.com/1lck/Lithe-IDEA/releases/download/desktop-v0.8.5/lithe-0.8.5-darwin-amd64.zip) | +| Windows x64 | [Installer](https://github.com/1lck/Lithe-IDEA/releases/download/desktop-v0.8.5/lithe-0.8.5-windows-amd64-setup.exe) · [ZIP](https://github.com/1lck/Lithe-IDEA/releases/download/desktop-v0.8.5/lithe-0.8.5-windows-amd64.zip) | +| Linux x64 | [DEB](https://github.com/1lck/Lithe-IDEA/releases/download/desktop-v0.8.5/lithe_0.8.5_amd64.deb) · [RPM](https://github.com/1lck/Lithe-IDEA/releases/download/desktop-v0.8.5/lithe-0.8.5-1.x86_64.rpm) · [tar.gz](https://github.com/1lck/Lithe-IDEA/releases/download/desktop-v0.8.5/lithe-0.8.5-linux-amd64.tar.gz) | +| Linux ARM64 | [DEB](https://github.com/1lck/Lithe-IDEA/releases/download/desktop-v0.8.5/lithe_0.8.5_arm64.deb) · [RPM](https://github.com/1lck/Lithe-IDEA/releases/download/desktop-v0.8.5/lithe-0.8.5-1.aarch64.rpm) · [tar.gz](https://github.com/1lck/Lithe-IDEA/releases/download/desktop-v0.8.5/lithe-0.8.5-linux-arm64.tar.gz) | + +### Highlights + +This release focuses on run configurations and multi-repository Git. + +#### ✨ New features + +- Create and run Shell, PowerShell, cmd script and executable run configurations without any plugin. +- Run several run configurations at the same time, each with its own console. +- Run configurations can list steps before launch that run other configurations first, in order. +- Open a Java class with a main method, choose Current File and press Run to run it and save it as a run configuration. +- In a folder with several repositories, the branch popup lists common branches to check out or create in all of them. +- When a multi-repository checkout succeeds in only some repositories, roll the finished ones back in one step. + +#### ⚡ Improvements + +- Web addresses in the console are clickable and open in the browser. +- Running configurations show a steady running icon in lists and tabs. +- The combined multi-repository log highlights the current branch of every repository. +- The sidebar "…" button can be dragged and moved like other buttons; the placeholder Updates entry is removed. +- On Windows, resizing the window stays smooth and no longer stretches the content. + +#### 🛠 Fixes + +- The first item of the editor and gutter context menus can be clicked. +- On Linux Wayland, the keyboard and input method keep working after clicking content. + +### Upgrade instructions + +- From 0.8.4: check for updates from the title-bar update entry or Settings → Updates to update in-app; earlier versions download the full package. +- Windows 0.8.0 cannot finish an in-app update; download and run this release's installer instead. +- macOS: or open the DMG for your processor and drag `Lithe Desktop.app` to Applications. +- Homebrew: run `brew update && brew upgrade --cask lithe` after the cask is updated to this release. +- Windows: run the x64 installer, or extract the ZIP into its own directory and run `lithe.exe`. +- Linux: use the DEB/RPM for your architecture; tar.gz users must provide the required runtime libraries. + +### Compatibility and known issues + +- Run configurations are now stored as YAML files under `.lithe/run/`; old JSON files convert on first edit, after which 0.8.4 and earlier cannot read them. +- Running a Java class from the current file needs the Maven plugin 1.0.1 or later, which needs this desktop version or newer. +- macOS requires 13.0 or newer, with separate Apple Silicon and Intel packages; the Windows desktop package targets x64. +- Linux packages target x64 and ARM64, requiring compatible libraries and a graphical environment; not every distribution is verified. +- Generated run configurations, service debugging and hiding folders such as `target` and `node_modules` need the matching language or build plugin enabled. +- Feature migration continues; some features of the older client are not yet at full parity. +- macOS packages use ad hoc signing without notarization; Windows installers have no publisher signature and may trigger system prompts. + +If macOS cannot open `Lithe Desktop.app`, Control-click it in Applications and choose Open. If it remains blocked, run `xattr -dr com.apple.quarantine "/Applications/Lithe Desktop.app"`. For the older `Lithe.app`, use `xattr -dr com.apple.quarantine /Applications/Lithe.app`. Use these commands only for an app from a source you trust. + +[Full changelog](https://github.com/1lck/Lithe-IDEA/compare/desktop-v0.8.4...desktop-v0.8.5) + +### 🙌 感谢贡献者 + +感谢 [@1lck](https://github.com/1lck) 和 [@xiaoyumuxi](https://github.com/xiaoyumuxi)。 + +### 🙌 Contributors + +Thanks to [@1lck](https://github.com/1lck) and [@xiaoyumuxi](https://github.com/xiaoyumuxi). diff --git a/shared/platform-feature-matrix/features/readonly-text-selection.json b/shared/platform-feature-matrix/features/readonly-text-selection.json index 1cb6f36d38..713d04150f 100644 --- a/shared/platform-feature-matrix/features/readonly-text-selection.json +++ b/shared/platform-feature-matrix/features/readonly-text-selection.json @@ -4,18 +4,13 @@ "group": "只读文本", "capability": "只读文本区域可以像 IntelliJ IDEA 那样选择和复制:Run 窗口控制台、测试输出、Git Log 提交详情和 Git 工具窗口的 Console支持拖动选择(含跨行和拖出边缘自动滚动)、双击选词、三击选行、Shift+点击扩展选区、Cmd/Ctrl+A 全选、Cmd/Ctrl+C 复制、Esc 取消选择,右键菜单提供复制、全选(Run 控制台另有复制输出);内容不可编辑", "owner": "Workbench", - "notes": "Viva 共享实现,在 desktop/internal/textview:按等宽字符格逐行绘制,只声明屏幕上的行;选区按控制台行序号记录,最早的行被丢弃时选区跟着文字,不会错位。控制台保留 ANSI 颜色与样式、输出链接点击打开(链接上按下拖动仍是选择)、自动跟随最新输出、清空和滚动到末尾;右键菜单在有选区时复制选区,否则复制右键所在行。Git 提交详情把标题、哈希/作者/邮箱/日期和正文作为一段等宽文字自动换行显示,引用标签移到文字下方。Git Console(gitconsole_view.go)同样改用 textview:命令头的临时配置仍是可点击的折叠开关(行内链接,悬停变强调色),其他折叠的“展开 N 行”开关和运行中徽标画在行尾、不进入选区;不换行时长行仍以省略号结尾,换行时为行尾开关留出列;搜索命中行高亮、跳到命中时居中滚动;折叠展开或新增命令重新排行后,选区跟着原来的行,原来的行变了才取消;右键菜单保留复制命令、复制输出、复制路径。", - "verification": "运行会抛出异常的程序,在 Run 窗口控制台从第一行中间拖到第三行,Cmd/Ctrl+C 后粘贴得到原样的堆栈文字;双击类名只选中该词,三击选中整行;点击后 Shift+点击扩展选区;Cmd/Ctrl+A 全选,Esc 取消;右键菜单的复制、复制输出、全选可用;点击文件链接仍能打开;输出持续追加时仍跟随最新行。在 Git Log 选中提交,双击哈希复制、拖动选择作者邮箱、全选复制整段提交信息,确认不能输入修改。在 Git 工具窗口的 Console 执行 fetch/pull 后,拖动跨行选择并复制,右键复制当前行和全选,点击“展开 N 行”和命令头的临时配置仍能展开折叠,搜索后上下跳转命中仍滚到命中行。自动化:textview/selection_test.go、workbench/console_selection_test.go、workbench/gitconsole_test.go、workbench/gitlog_details_test.go、workbench/context_menu_test.go、workbench/run_panels_test.go。", + "notes": "Viva 共享实现,使用 Viva 的 ui/textview(Lithe-IDEA/Lithe-viva#36,对应上游 vivaui/viva#337;原先 Lithe 自带的 desktop/internal/textview 副本已删除):按等宽字符格逐行绘制,只声明屏幕上的行;选区按控制台行序号记录,最早的行被丢弃时选区跟着文字,不会错位。控制台保留 ANSI 颜色与样式、输出链接点击打开(链接上按下拖动仍是选择)、自动跟随最新输出、清空和滚动到末尾;右键菜单在有选区时复制选区,否则复制右键所在行。Git 提交详情把标题、哈希/作者/邮箱/日期和正文作为一段等宽文字自动换行显示,引用标签移到文字下方。Git Console(gitconsole_view.go)同样改用 textview:命令头的临时配置仍是可点击的折叠开关(行内链接,悬停变强调色),其他折叠的“展开 N 行”开关和运行中徽标画在行尾、不进入选区;不换行时长行仍以省略号结尾,换行时为行尾开关留出列;搜索命中行高亮、跳到命中时居中滚动;折叠展开或新增命令重新排行后,选区跟着原来的行,原来的行变了才取消;右键菜单保留复制命令、复制输出、复制路径。", + "verification": "运行会抛出异常的程序,在 Run 窗口控制台从第一行中间拖到第三行,Cmd/Ctrl+C 后粘贴得到原样的堆栈文字;双击类名只选中该词,三击选中整行;点击后 Shift+点击扩展选区;Cmd/Ctrl+A 全选,Esc 取消;右键菜单的复制、复制输出、全选可用;点击文件链接仍能打开;输出持续追加时仍跟随最新行。在 Git Log 选中提交,双击哈希复制、拖动选择作者邮箱、全选复制整段提交信息,确认不能输入修改。在 Git 工具窗口的 Console 执行 fetch/pull 后,拖动跨行选择并复制,右键复制当前行和全选,点击“展开 N 行”和命令头的临时配置仍能展开折叠,搜索后上下跳转命中仍滚到命中行。自动化:Viva 的 ui/textview 测试、workbench/console_selection_test.go、workbench/gitconsole_test.go、workbench/gitlog_details_test.go、workbench/context_menu_test.go、workbench/run_panels_test.go。", "macos": { "implementationStatus": "implemented", "verificationStatus": "pending", "evidence": [ - "desktop/internal/textview/view.go", - "desktop/internal/textview/selection.go", - "desktop/internal/textview/rows.go", - "desktop/internal/textview/paint.go", - "desktop/internal/textview/cells.go", - "desktop/internal/textview/selection_test.go", + "desktop/go.mod", "desktop/internal/workbench/outputlinks_view.go", "desktop/internal/workbench/run_view.go", "desktop/internal/workbench/gitlog_details_view.go", @@ -24,19 +19,15 @@ "desktop/internal/workbench/context_menu_test.go", "desktop/internal/workbench/gitconsole_view.go", "desktop/internal/workbench/gitconsole.go", - "desktop/internal/workbench/gitconsole_test.go" + "desktop/internal/workbench/gitconsole_test.go", + "desktop/internal/workbench/runpanels.go" ] }, "windows": { "implementationStatus": "implemented", "verificationStatus": "pending", "evidence": [ - "desktop/internal/textview/view.go", - "desktop/internal/textview/selection.go", - "desktop/internal/textview/rows.go", - "desktop/internal/textview/paint.go", - "desktop/internal/textview/cells.go", - "desktop/internal/textview/selection_test.go", + "desktop/go.mod", "desktop/internal/workbench/outputlinks_view.go", "desktop/internal/workbench/run_view.go", "desktop/internal/workbench/gitlog_details_view.go", @@ -45,7 +36,8 @@ "desktop/internal/workbench/context_menu_test.go", "desktop/internal/workbench/gitconsole_view.go", "desktop/internal/workbench/gitconsole.go", - "desktop/internal/workbench/gitconsole_test.go" + "desktop/internal/workbench/gitconsole_test.go", + "desktop/internal/workbench/runpanels.go" ] } }