|
|
|
@ -100,7 +100,7 @@ type Terminal struct {
|
|
|
|
|
margin [4]sizeSpec
|
|
|
|
|
strong tui.Attr
|
|
|
|
|
unicode bool
|
|
|
|
|
bordered bool
|
|
|
|
|
borderShape tui.BorderShape
|
|
|
|
|
cleanExit bool
|
|
|
|
|
border tui.Window
|
|
|
|
|
window tui.Window
|
|
|
|
@ -370,9 +370,9 @@ func NewTerminal(opts *Options, eventBox *util.EventBox) *Terminal {
|
|
|
|
|
effectiveMinHeight *= 2
|
|
|
|
|
}
|
|
|
|
|
if opts.InfoStyle != infoDefault {
|
|
|
|
|
effectiveMinHeight -= 1
|
|
|
|
|
effectiveMinHeight--
|
|
|
|
|
}
|
|
|
|
|
if opts.Bordered {
|
|
|
|
|
if opts.BorderShape != tui.BorderNone {
|
|
|
|
|
effectiveMinHeight += 2
|
|
|
|
|
}
|
|
|
|
|
return util.Min(termHeight, util.Max(maxHeight, effectiveMinHeight))
|
|
|
|
@ -391,62 +391,62 @@ func NewTerminal(opts *Options, eventBox *util.EventBox) *Terminal {
|
|
|
|
|
spinner = []string{`-`, `\`, `|`, `/`, `-`, `\`, `|`, `/`}
|
|
|
|
|
}
|
|
|
|
|
t := Terminal{
|
|
|
|
|
initDelay: delay,
|
|
|
|
|
infoStyle: opts.InfoStyle,
|
|
|
|
|
spinner: spinner,
|
|
|
|
|
queryLen: [2]int{0, 0},
|
|
|
|
|
layout: opts.Layout,
|
|
|
|
|
fullscreen: fullscreen,
|
|
|
|
|
hscroll: opts.Hscroll,
|
|
|
|
|
hscrollOff: opts.HscrollOff,
|
|
|
|
|
wordRubout: wordRubout,
|
|
|
|
|
wordNext: wordNext,
|
|
|
|
|
cx: len(input),
|
|
|
|
|
cy: 0,
|
|
|
|
|
offset: 0,
|
|
|
|
|
xoffset: 0,
|
|
|
|
|
yanked: []rune{},
|
|
|
|
|
input: input,
|
|
|
|
|
multi: opts.Multi,
|
|
|
|
|
sort: opts.Sort > 0,
|
|
|
|
|
toggleSort: opts.ToggleSort,
|
|
|
|
|
delimiter: opts.Delimiter,
|
|
|
|
|
expect: opts.Expect,
|
|
|
|
|
keymap: opts.Keymap,
|
|
|
|
|
pressed: "",
|
|
|
|
|
printQuery: opts.PrintQuery,
|
|
|
|
|
history: opts.History,
|
|
|
|
|
margin: opts.Margin,
|
|
|
|
|
unicode: opts.Unicode,
|
|
|
|
|
bordered: opts.Bordered,
|
|
|
|
|
cleanExit: opts.ClearOnExit,
|
|
|
|
|
strong: strongAttr,
|
|
|
|
|
cycle: opts.Cycle,
|
|
|
|
|
header: header,
|
|
|
|
|
header0: header,
|
|
|
|
|
ansi: opts.Ansi,
|
|
|
|
|
tabstop: opts.Tabstop,
|
|
|
|
|
reading: true,
|
|
|
|
|
failed: nil,
|
|
|
|
|
jumping: jumpDisabled,
|
|
|
|
|
jumpLabels: opts.JumpLabels,
|
|
|
|
|
printer: opts.Printer,
|
|
|
|
|
printsep: opts.PrintSep,
|
|
|
|
|
merger: EmptyMerger,
|
|
|
|
|
selected: make(map[int32]selectedItem),
|
|
|
|
|
reqBox: util.NewEventBox(),
|
|
|
|
|
preview: opts.Preview,
|
|
|
|
|
previewer: previewer{"", 0, 0, previewBox != nil && !opts.Preview.hidden, false},
|
|
|
|
|
previewBox: previewBox,
|
|
|
|
|
eventBox: eventBox,
|
|
|
|
|
mutex: sync.Mutex{},
|
|
|
|
|
suppress: true,
|
|
|
|
|
slab: util.MakeSlab(slab16Size, slab32Size),
|
|
|
|
|
theme: opts.Theme,
|
|
|
|
|
startChan: make(chan bool, 1),
|
|
|
|
|
killChan: make(chan int),
|
|
|
|
|
tui: renderer,
|
|
|
|
|
initFunc: func() { renderer.Init() }}
|
|
|
|
|
initDelay: delay,
|
|
|
|
|
infoStyle: opts.InfoStyle,
|
|
|
|
|
spinner: spinner,
|
|
|
|
|
queryLen: [2]int{0, 0},
|
|
|
|
|
layout: opts.Layout,
|
|
|
|
|
fullscreen: fullscreen,
|
|
|
|
|
hscroll: opts.Hscroll,
|
|
|
|
|
hscrollOff: opts.HscrollOff,
|
|
|
|
|
wordRubout: wordRubout,
|
|
|
|
|
wordNext: wordNext,
|
|
|
|
|
cx: len(input),
|
|
|
|
|
cy: 0,
|
|
|
|
|
offset: 0,
|
|
|
|
|
xoffset: 0,
|
|
|
|
|
yanked: []rune{},
|
|
|
|
|
input: input,
|
|
|
|
|
multi: opts.Multi,
|
|
|
|
|
sort: opts.Sort > 0,
|
|
|
|
|
toggleSort: opts.ToggleSort,
|
|
|
|
|
delimiter: opts.Delimiter,
|
|
|
|
|
expect: opts.Expect,
|
|
|
|
|
keymap: opts.Keymap,
|
|
|
|
|
pressed: "",
|
|
|
|
|
printQuery: opts.PrintQuery,
|
|
|
|
|
history: opts.History,
|
|
|
|
|
margin: opts.Margin,
|
|
|
|
|
unicode: opts.Unicode,
|
|
|
|
|
borderShape: opts.BorderShape,
|
|
|
|
|
cleanExit: opts.ClearOnExit,
|
|
|
|
|
strong: strongAttr,
|
|
|
|
|
cycle: opts.Cycle,
|
|
|
|
|
header: header,
|
|
|
|
|
header0: header,
|
|
|
|
|
ansi: opts.Ansi,
|
|
|
|
|
tabstop: opts.Tabstop,
|
|
|
|
|
reading: true,
|
|
|
|
|
failed: nil,
|
|
|
|
|
jumping: jumpDisabled,
|
|
|
|
|
jumpLabels: opts.JumpLabels,
|
|
|
|
|
printer: opts.Printer,
|
|
|
|
|
printsep: opts.PrintSep,
|
|
|
|
|
merger: EmptyMerger,
|
|
|
|
|
selected: make(map[int32]selectedItem),
|
|
|
|
|
reqBox: util.NewEventBox(),
|
|
|
|
|
preview: opts.Preview,
|
|
|
|
|
previewer: previewer{"", 0, 0, previewBox != nil && !opts.Preview.hidden, false},
|
|
|
|
|
previewBox: previewBox,
|
|
|
|
|
eventBox: eventBox,
|
|
|
|
|
mutex: sync.Mutex{},
|
|
|
|
|
suppress: true,
|
|
|
|
|
slab: util.MakeSlab(slab16Size, slab32Size),
|
|
|
|
|
theme: opts.Theme,
|
|
|
|
|
startChan: make(chan bool, 1),
|
|
|
|
|
killChan: make(chan int),
|
|
|
|
|
tui: renderer,
|
|
|
|
|
initFunc: func() { renderer.Init() }}
|
|
|
|
|
t.prompt, t.promptLen = t.processTabs([]rune(opts.Prompt), 0)
|
|
|
|
|
t.pointer, t.pointerLen = t.processTabs([]rune(opts.Pointer), 0)
|
|
|
|
|
t.marker, t.markerLen = t.processTabs([]rune(opts.Marker), 0)
|
|
|
|
@ -595,8 +595,11 @@ func (t *Terminal) resizeWindows() {
|
|
|
|
|
} else {
|
|
|
|
|
marginInt[idx] = int(sizeSpec.size)
|
|
|
|
|
}
|
|
|
|
|
if t.bordered && idx%2 == 0 {
|
|
|
|
|
marginInt[idx] += 1
|
|
|
|
|
switch t.borderShape {
|
|
|
|
|
case tui.BorderHorizontal:
|
|
|
|
|
marginInt[idx] += 1 - idx%2
|
|
|
|
|
case tui.BorderRounded, tui.BorderSharp:
|
|
|
|
|
marginInt[idx] += 1 + idx%2
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
adjust := func(idx1 int, idx2 int, max int, min int) {
|
|
|
|
@ -636,18 +639,26 @@ func (t *Terminal) resizeWindows() {
|
|
|
|
|
|
|
|
|
|
width := screenWidth - marginInt[1] - marginInt[3]
|
|
|
|
|
height := screenHeight - marginInt[0] - marginInt[2]
|
|
|
|
|
if t.bordered {
|
|
|
|
|
switch t.borderShape {
|
|
|
|
|
case tui.BorderHorizontal:
|
|
|
|
|
t.border = t.tui.NewWindow(
|
|
|
|
|
marginInt[0]-1,
|
|
|
|
|
marginInt[3],
|
|
|
|
|
width,
|
|
|
|
|
height+2,
|
|
|
|
|
false, tui.MakeBorderStyle(tui.BorderHorizontal, t.unicode))
|
|
|
|
|
case tui.BorderRounded, tui.BorderSharp:
|
|
|
|
|
t.border = t.tui.NewWindow(
|
|
|
|
|
marginInt[0]-1,
|
|
|
|
|
marginInt[3]-2,
|
|
|
|
|
width+4,
|
|
|
|
|
height+2,
|
|
|
|
|
false, tui.MakeBorderStyle(t.borderShape, t.unicode))
|
|
|
|
|
}
|
|
|
|
|
noBorder := tui.MakeBorderStyle(tui.BorderNone, t.unicode)
|
|
|
|
|
if previewVisible {
|
|
|
|
|
createPreviewWindow := func(y int, x int, w int, h int) {
|
|
|
|
|
previewBorder := tui.MakeBorderStyle(tui.BorderAround, t.unicode)
|
|
|
|
|
previewBorder := tui.MakeBorderStyle(tui.BorderRounded, t.unicode)
|
|
|
|
|
if !t.preview.border {
|
|
|
|
|
previewBorder = tui.MakeTransparentBorder()
|
|
|
|
|
}
|
|
|
|
@ -1146,7 +1157,7 @@ func (t *Terminal) refresh() {
|
|
|
|
|
t.placeCursor()
|
|
|
|
|
if !t.suppress {
|
|
|
|
|
windows := make([]tui.Window, 0, 4)
|
|
|
|
|
if t.bordered {
|
|
|
|
|
if t.borderShape != tui.BorderNone {
|
|
|
|
|
windows = append(windows, t.border)
|
|
|
|
|
}
|
|
|
|
|
if t.hasPreviewWindow() {
|
|
|
|
|