Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting foreground without background. #712

Closed
damage220 opened this issue Oct 21, 2016 · 12 comments
Closed

Setting foreground without background. #712

damage220 opened this issue Oct 21, 2016 · 12 comments
Labels

Comments

@damage220
Copy link

@damage220 damage220 commented Oct 21, 2016

  • Category
    • fzf binary
    • fzf-tmux script
    • Key bindings
    • Completion
    • Vim
    • Neovim
    • Etc.
  • OS
    • Linux
    • Mac OS X
    • Windows
    • Etc.
  • Shell
    • bash
    • zsh
    • fish

It seems that there is no opportunity to set fg color without bg. I want to set fg to 109 and don't change bg (because I use hex value in my gnome-terminal). When I do this, bg is set to 0 (which is a little bit lighter than terminal bg). When I've set bg to -1, fg is restored to white. So the proposition is to implement this feature. It would be also nice if there is more freedom in configuring highlighting, e.g. style (bold, underline) or different groups for left bar and selected item.

I used this command:
.fzf/bin/fzf --color=fg:109,bg:-1

@junegunn junegunn mentioned this issue Oct 21, 2016
4 of 14 tasks complete
@junegunn
Copy link
Owner

@junegunn junegunn commented Oct 21, 2016

I think I did so because I noticed that it was impossible to set foreground color alone. It could be a limitation or a bug of ncurses, but I'm not sure.

#include <ncurses.h>
#include <stdlib.h>

int main(int argc, char **argv)
{
  initscr();
  start_color();
  int bg = argc > 1 ? atoi(argv[1]) : -1;
  assume_default_colors(123, bg);
  printw("hello world");
  refresh();
  getch();
  endwin();
  return 0;
}

Compile it (gcc foo.c -lncurses) and run it with different arguments (./a.out -1, ./a.out 0, ./a.out 1). The foreground color is not correctly set if bg is -1 (default color).

Need further investigation.

@junegunn
Copy link
Owner

@junegunn junegunn commented Oct 21, 2016

I think I can fix this by assigning an extra color pair instead of using 0. I'll let you know of the progress.

@junegunn
Copy link
Owner

@junegunn junegunn commented Oct 21, 2016

Pushed the fix. Let me know if you see any issues. The patch will be included in the next version which I'm going to release pretty soon.

It would be also nice if there is more freedom in configuring highlighting, e.g. style (bold, underline) or different groups for left bar and selected item.

It requires revising the syntax for color specification. Not now, but maybe in the future.

@damage220
Copy link
Author

@damage220 damage220 commented Oct 22, 2016

I don't see any changes.

git clone git@github.com:junegunn/fzf.git .fzf
.fzf/install --bin

What did I do wrong?

@junegunn
Copy link
Owner

@junegunn junegunn commented Oct 22, 2016

Nothing. I haven't released a new binary. Until then you have to build from source.

@junegunn
Copy link
Owner

@junegunn junegunn commented Oct 23, 2016

I just released 0.15.5, please try again.

@damage220
Copy link
Author

@damage220 damage220 commented Oct 23, 2016

No issues were found. I appreciate your effort.

@gkapfham
Copy link

@gkapfham gkapfham commented Nov 13, 2016

Hello @junegunn! Thank you very much for developing fzf and fzf.vim! I use both the program and the Vim plugin on a very regular basis. Your work is very much appreciate by me.

I know that this issue is now closed. But, I noticed that you wrote "It requires revising the syntax for color specification. Not now, but maybe in the future." and I wanted to chime in to say that I would really appreciate the addition of this feature. Right now, when I use fzf I notice that it always highlights the current line in a bold font.

While I agree that this is a suitable approach, I find the transition from a normal font, to a bold one, and then back to a normal font (as I am, say, going up and down a list of files) to be slightly jarring. Is there a current way to highlight the current line without using the bold font? Or, is this what you were referencing in the aforementioned quote when you said that you would revise the color specification in the future?

@junegunn
Copy link
Owner

@junegunn junegunn commented Nov 13, 2016

@gkapfham I'm not sure. I've expressed my reluctance to add more options for styling visual elements a few times in the past (#692). For now, consider compiling fzf from source. The following patch will do.

diff --git a/src/terminal.go b/src/terminal.go
index 6d1a1ab..a2e2ddf 100644
--- a/src/terminal.go
+++ b/src/terminal.go
@@ -630,11 +630,11 @@ func (t *Terminal) printItem(result *Result, i int, current bool) {
    t.window.CPrint(tui.ColCursor, tui.Bold, label)
    if current {
        if selected {
-           t.window.CPrint(tui.ColSelected, tui.Bold, ">")
+           t.window.CPrint(tui.ColSelected, 0, ">")
        } else {
-           t.window.CPrint(tui.ColCurrent, tui.Bold, " ")
+           t.window.CPrint(tui.ColCurrent, 0, " ")
        }
-       t.printHighlighted(result, tui.Bold, tui.ColCurrent, tui.ColCurrentMatch, true)
+       t.printHighlighted(result, 0, tui.ColCurrent, tui.ColCurrentMatch, true)
    } else {
        if selected {
            t.window.CPrint(tui.ColSelected, tui.Bold, ">")
@gkapfham
Copy link

@gkapfham gkapfham commented Nov 14, 2016

Hello @junegunn. Again, thanks for developing fzf and thanks for sharing the patch with me. I will consider compiling from source in the future. For now, I will accept the bold font. If you ever decide to implement some of the requested styling features, then let us know. Overall, I really appreciate your effort in creating this very useful program!

@junegunn
Copy link
Owner

@junegunn junegunn commented Nov 19, 2016

@gkapfham --no-bold option is added in 0.15.8. You can add it to your $FZF_DEFAULT_OPTS.

@gkapfham
Copy link

@gkapfham gkapfham commented Dec 27, 2016

Hello @junegunn! Please accept my apology for the delay in my reply on this issue. Again, thanks so much for all of your hard work on this plugin! I was delighted to see that you added the --no-bold option and I have added it to my $FZF_DEFAULT_OPTS so that it is the default when I am using fzf in Vim, NeoVim, and in my terminal. Again, your addition of this option is greatly appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.