Add --no-bold option

This commit is contained in:
Junegunn Choi 2016-11-15 23:57:32 +09:00
parent 22487810ba
commit 4b332d831e
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627
4 changed files with 33 additions and 20 deletions

View File

@ -57,6 +57,7 @@ const usage = `usage: fzf [options]
--ansi Enable processing of ANSI color codes
--tabstop=SPACES Number of spaces for a tab character (default: 8)
--color=COLSPEC Base scheme (dark|light|16|bw) and/or custom colors
--no-bold Do not use bold text
History
--history=FILE History file
@ -144,6 +145,7 @@ type Options struct {
Mouse bool
Theme *tui.ColorTheme
Black bool
Bold bool
Reverse bool
Cycle bool
Hscroll bool
@ -189,6 +191,7 @@ func defaultOptions() *Options {
Mouse: true,
Theme: tui.EmptyTheme(),
Black: false,
Bold: true,
Reverse: false,
Cycle: false,
Hscroll: true,
@ -910,6 +913,10 @@ func parseOptions(opts *Options, allArgs []string) {
opts.Black = true
case "--no-black":
opts.Black = false
case "--bold":
opts.Bold = true
case "--no-bold":
opts.Bold = false
case "--reverse":
opts.Reverse = true
case "--no-reverse":

View File

@ -70,6 +70,7 @@ type Terminal struct {
header0 []string
ansi bool
margin [4]sizeSpec
strong tui.Attr
window *tui.Window
bwindow *tui.Window
pwindow *tui.Window
@ -256,6 +257,10 @@ func NewTerminal(opts *Options, eventBox *util.EventBox) *Terminal {
if len(opts.Preview.command) > 0 {
previewBox = util.NewEventBox()
}
strongAttr := tui.Bold
if !opts.Bold {
strongAttr = tui.AttrRegular
}
return &Terminal{
initDelay: delay,
inlineInfo: opts.InlineInfo,
@ -279,6 +284,7 @@ func NewTerminal(opts *Options, eventBox *util.EventBox) *Terminal {
printQuery: opts.PrintQuery,
history: opts.History,
margin: opts.Margin,
strong: strongAttr,
cycle: opts.Cycle,
header: header,
header0: header,
@ -532,24 +538,24 @@ func (t *Terminal) placeCursor() {
func (t *Terminal) printPrompt() {
t.move(0, 0, true)
t.window.CPrint(tui.ColPrompt, tui.Bold, t.prompt)
t.window.CPrint(tui.ColNormal, tui.Bold, string(t.input))
t.window.CPrint(tui.ColPrompt, t.strong, t.prompt)
t.window.CPrint(tui.ColNormal, t.strong, string(t.input))
}
func (t *Terminal) printInfo() {
if t.inlineInfo {
t.move(0, displayWidth([]rune(t.prompt))+displayWidth(t.input)+1, true)
if t.reading {
t.window.CPrint(tui.ColSpinner, tui.Bold, " < ")
t.window.CPrint(tui.ColSpinner, t.strong, " < ")
} else {
t.window.CPrint(tui.ColPrompt, tui.Bold, " < ")
t.window.CPrint(tui.ColPrompt, t.strong, " < ")
}
} else {
t.move(1, 0, true)
if t.reading {
duration := int64(spinnerDuration)
idx := (time.Now().UnixNano() % (duration * int64(len(_spinner)))) / duration
t.window.CPrint(tui.ColSpinner, tui.Bold, _spinner[idx])
t.window.CPrint(tui.ColSpinner, t.strong, _spinner[idx])
}
t.move(1, 2, false)
}
@ -627,17 +633,17 @@ func (t *Terminal) printItem(result *Result, i int, current bool) {
} else if current {
label = ">"
}
t.window.CPrint(tui.ColCursor, tui.Bold, label)
t.window.CPrint(tui.ColCursor, t.strong, label)
if current {
if selected {
t.window.CPrint(tui.ColSelected, tui.Bold, ">")
t.window.CPrint(tui.ColSelected, t.strong, ">")
} else {
t.window.CPrint(tui.ColCurrent, tui.Bold, " ")
t.window.CPrint(tui.ColCurrent, t.strong, " ")
}
t.printHighlighted(result, tui.Bold, tui.ColCurrent, tui.ColCurrentMatch, true)
t.printHighlighted(result, t.strong, tui.ColCurrent, tui.ColCurrentMatch, true)
} else {
if selected {
t.window.CPrint(tui.ColSelected, tui.Bold, ">")
t.window.CPrint(tui.ColSelected, t.strong, ">")
} else {
t.window.Print(" ")
}

View File

@ -30,11 +30,11 @@ type Attr C.int
type WindowImpl C.WINDOW
const (
Bold = C.A_BOLD
Dim = C.A_DIM
Blink = C.A_BLINK
Reverse = C.A_REVERSE
Underline = C.A_UNDERLINE
Bold Attr = C.A_BOLD
Dim = C.A_DIM
Blink = C.A_BLINK
Reverse = C.A_REVERSE
Underline = C.A_UNDERLINE
)
const (

View File

@ -43,11 +43,11 @@ type WindowTcell struct {
type WindowImpl WindowTcell
const (
Bold = Attr(tcell.AttrBold)
Dim = Attr(tcell.AttrDim)
Blink = Attr(tcell.AttrBlink)
Reverse = Attr(tcell.AttrReverse)
Underline = Attr(tcell.AttrUnderline)
Bold Attr = Attr(tcell.AttrBold)
Dim = Attr(tcell.AttrDim)
Blink = Attr(tcell.AttrBlink)
Reverse = Attr(tcell.AttrReverse)
Underline = Attr(tcell.AttrUnderline)
)
const (