67 lines
2.2 KiB
Go
67 lines
2.2 KiB
Go
// Fenrir console screen reader.
|
|
// Copyright (c) 2026 Storm Dragon
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
//
|
|
// This program is free software: you can redistribute it and/or modify it
|
|
// under the terms of the GNU General Public License as published by the Free
|
|
// Software Foundation, either version 3 of the License, or (at your option)
|
|
// any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful, but WITHOUT
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
// more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License along with
|
|
// this program. If not, see <https://www.gnu.org/licenses/gpl-3.0.html>.
|
|
|
|
package review
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"git.stormux.org/storm/fenrir/internal/command"
|
|
"git.stormux.org/storm/fenrir/internal/presentation"
|
|
"git.stormux.org/storm/fenrir/internal/screen"
|
|
)
|
|
|
|
func TestMarksUnicodeReverseSingleMarkAndSessionRetirement(t *testing.T) {
|
|
snapshot := screen.Snapshot{Active: true, Terminal: 1, Rows: 2, Cols: 5, Cells: []rune("é界abcnext ")}
|
|
var review Review
|
|
review.Update(snapshot)
|
|
if got := review.Set_mark(); got.Text != "no review cursor" {
|
|
t.Fatal(got)
|
|
}
|
|
review.Execute(command.CurrentChar)
|
|
if got := review.Set_mark(); got.Cue != presentation.PlaceStartMark {
|
|
t.Fatal(got)
|
|
}
|
|
review.Execute(command.NextChar)
|
|
if text, ok := review.Marked_text(true); !ok || text != "é界" {
|
|
t.Fatal(text, ok)
|
|
}
|
|
if _, ok := review.Marked_text(false); ok {
|
|
t.Fatal("preview accepted one mark")
|
|
}
|
|
review.Execute(command.NextLine)
|
|
if got := review.Set_mark(); got.Cue != presentation.PlaceEndMark {
|
|
t.Fatal(got)
|
|
}
|
|
if text, ok := review.Marked_text(false); !ok || text != "é界abc\nne" {
|
|
t.Fatal(text, ok)
|
|
}
|
|
review.Clear_marks()
|
|
review.Set_mark()
|
|
review.Execute(command.Top)
|
|
review.Execute(command.LineStart)
|
|
review.Set_mark()
|
|
if text, ok := review.Marked_text(false); !ok || text != "é界abc\nne" {
|
|
t.Fatal("reverse selection", text, ok)
|
|
}
|
|
snapshot.Generation++
|
|
review.Update(snapshot)
|
|
if _, ok := review.Marked_text(true); ok {
|
|
t.Fatal("marks survived screen replacement")
|
|
}
|
|
}
|