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

View File

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

View File

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

View File

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