mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2024-12-23 19:39:07 +00:00
[ncurses6] Use wcolor_set to support more than 256 color pairs
To build fzf with ncurses 6 on macOS: brew install homebrew/dupes/ncurses LDFLAGS="-L/usr/local/opt/ncurses/lib" make install
This commit is contained in:
parent
43425158f4
commit
af31088481
@ -70,10 +70,10 @@ clean:
|
|||||||
cd fzf && rm -f fzf-*
|
cd fzf && rm -f fzf-*
|
||||||
|
|
||||||
fzf/$(BINARY32): deps
|
fzf/$(BINARY32): deps
|
||||||
cd fzf && GOARCH=386 CGO_ENABLED=1 go build -a -ldflags -w -tags "$(TAGS)" -o $(BINARY32)
|
cd fzf && GOARCH=386 CGO_ENABLED=1 go build -a -ldflags "-w -extldflags=$(LDFLAGS)" -tags "$(TAGS)" -o $(BINARY32)
|
||||||
|
|
||||||
fzf/$(BINARY64): deps
|
fzf/$(BINARY64): deps
|
||||||
cd fzf && go build -a -ldflags -w -tags "$(TAGS)" -o $(BINARY64)
|
cd fzf && go build -a -ldflags "-w -extldflags=$(LDFLAGS)" -tags "$(TAGS)" -o $(BINARY64)
|
||||||
|
|
||||||
$(BINDIR)/fzf: fzf/$(BINARY) | $(BINDIR)
|
$(BINDIR)/fzf: fzf/$(BINARY) | $(BINDIR)
|
||||||
cp -f fzf/$(BINARY) $(BINDIR)
|
cp -f fzf/$(BINARY) $(BINDIR)
|
||||||
|
@ -65,7 +65,7 @@ const (
|
|||||||
var (
|
var (
|
||||||
_screen *C.SCREEN
|
_screen *C.SCREEN
|
||||||
_colorMap map[int]ColorPair
|
_colorMap map[int]ColorPair
|
||||||
_colorFn func(ColorPair, Attr) C.int
|
_colorFn func(ColorPair, Attr) (C.short, C.int)
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -164,10 +164,12 @@ func NewWindow(top int, left int, width int, height int, border bool) *Window {
|
|||||||
C.wbkgd(win, C.chtype(C.COLOR_PAIR(C.int(ColNormal))))
|
C.wbkgd(win, C.chtype(C.COLOR_PAIR(C.int(ColNormal))))
|
||||||
}
|
}
|
||||||
if border {
|
if border {
|
||||||
attr := _colorFn(ColBorder, 0)
|
pair, attr := _colorFn(ColBorder, 0)
|
||||||
|
C.wcolor_set(win, pair, nil)
|
||||||
C.wattron(win, attr)
|
C.wattron(win, attr)
|
||||||
C.box(win, 0, 0)
|
C.box(win, 0, 0)
|
||||||
C.wattroff(win, attr)
|
C.wattroff(win, attr)
|
||||||
|
C.wcolor_set(win, 0, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
return &Window{
|
return &Window{
|
||||||
@ -179,15 +181,11 @@ func NewWindow(top int, left int, width int, height int, border bool) *Window {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func attrColored(pair ColorPair, a Attr) C.int {
|
func attrColored(pair ColorPair, a Attr) (C.short, C.int) {
|
||||||
var attr C.int
|
return C.short(pair), C.int(a)
|
||||||
if pair > 0 {
|
|
||||||
attr = C.COLOR_PAIR(C.int(pair))
|
|
||||||
}
|
|
||||||
return attr | C.int(a)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func attrMono(pair ColorPair, a Attr) C.int {
|
func attrMono(pair ColorPair, a Attr) (C.short, C.int) {
|
||||||
var attr C.int
|
var attr C.int
|
||||||
switch pair {
|
switch pair {
|
||||||
case ColCurrent:
|
case ColCurrent:
|
||||||
@ -200,7 +198,7 @@ func attrMono(pair ColorPair, a Attr) C.int {
|
|||||||
if C.int(a)&C.A_BOLD == C.A_BOLD {
|
if C.int(a)&C.A_BOLD == C.A_BOLD {
|
||||||
attr = attr | C.A_BOLD
|
attr = attr | C.A_BOLD
|
||||||
}
|
}
|
||||||
return attr
|
return 0, attr
|
||||||
}
|
}
|
||||||
|
|
||||||
func MaxX() int {
|
func MaxX() int {
|
||||||
@ -241,11 +239,13 @@ func (w *Window) Print(text string) {
|
|||||||
}, text)))
|
}, text)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Window) CPrint(pair ColorPair, a Attr, text string) {
|
func (w *Window) CPrint(pair ColorPair, attr Attr, text string) {
|
||||||
attr := _colorFn(pair, a)
|
p, a := _colorFn(pair, attr)
|
||||||
C.wattron(w.win(), attr)
|
C.wcolor_set(w.win(), p, nil)
|
||||||
|
C.wattron(w.win(), a)
|
||||||
w.Print(text)
|
w.Print(text)
|
||||||
C.wattroff(w.win(), attr)
|
C.wattroff(w.win(), a)
|
||||||
|
C.wcolor_set(w.win(), 0, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Clear() {
|
func Clear() {
|
||||||
@ -265,11 +265,13 @@ func (w *Window) Fill(str string) bool {
|
|||||||
return C.waddstr(w.win(), C.CString(str)) == C.OK
|
return C.waddstr(w.win(), C.CString(str)) == C.OK
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Window) CFill(str string, fg Color, bg Color, a Attr) bool {
|
func (w *Window) CFill(str string, fg Color, bg Color, attr Attr) bool {
|
||||||
attr := _colorFn(PairFor(fg, bg), a)
|
pair := PairFor(fg, bg)
|
||||||
C.wattron(w.win(), attr)
|
C.wcolor_set(w.win(), C.short(pair), nil)
|
||||||
|
C.wattron(w.win(), C.int(attr))
|
||||||
ret := w.Fill(str)
|
ret := w.Fill(str)
|
||||||
C.wattroff(w.win(), attr)
|
C.wattroff(w.win(), C.int(attr))
|
||||||
|
C.wcolor_set(w.win(), 0, nil)
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user