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

Icons #697

Merged
merged 6 commits into from Aug 16, 2020
Merged

Icons #697

merged 6 commits into from Aug 16, 2020

Conversation

KlzXS
Copy link
Collaborator

@KlzXS KlzXS commented Aug 12, 2020

Icons can be optionally be compiled in. They can be configured to be any printable string, although to get actual icons you need a patched font. This uses the icons-in-terminal.h generated header with the default configuration. I haven't included that header here as it should be generated when icons-in-terminal does its magic, so you can just copy that over to the sources folder.

Padding (also any printable string) can be added from both left and right. On my system I needed a single space from the right side to prevent it overlapping with the entry name. You will need to figure out the proper amount for yourself.

All the configuration is done in the new icons.h header.

The icons look good, I think they look much better if you apply the color of the entry to them so I did that.
I tested it on a directory with 3000+ files with all the extensions and I can't see a difference in load time.
Everything works when changing the number of columns.

When this gets merged I'll add a wiki entry explaining the usage there.

@KlzXS
Copy link
Collaborator Author

KlzXS commented Aug 12, 2020

I haven't included that header

I have. For the CI to be happy.

@0xACE
Copy link
Collaborator

0xACE commented Aug 12, 2020

I don't have patched fonts on my machines So I can't test this out. Could you provide a screenshot?

I'm not a fan of having the icons in the far left when you enable printent_long(), imho it should be the first thing to the left of the current file name.

@KlzXS
Copy link
Collaborator Author

KlzXS commented Aug 12, 2020

imho it should be the first thing to the left of the current file name.

Oops. Didn't realize where I put it. It's fixed now.

Could you provide a screenshot?

image
image

Some icons could look a bit better and it would be nice if they were all from a single font design, but I don't think I'll go looking for it.
Also forgive the red color I'm not sure why it's red. It wasn't an hour ago.

@jarun
Copy link
Owner

jarun commented Aug 12, 2020

@leovilok can you please review this too?

I need some time to get to this.

Makefile Outdated Show resolved Hide resolved
@jarun
Copy link
Owner

jarun commented Aug 12, 2020

I installed icons-in-terminal and can see them with /print_icons.sh. I am on xfce4-terminal.

But when I run nnn I see:

 ~E~U misc/
  ~E~U plugins/
  ~E~U src/
  ~H~[ CHANGELOG
  ~H~[ LICENSE
  ~H~[ Makefile
  ~H~[ nnn*
  ~H~[ nnn.1
  ~B~L README.md

What am I missing?

@0xACE
Copy link
Collaborator

0xACE commented Aug 12, 2020

Oops. Didn't realize where I put it. It's fixed now.

Btw another detail I'd bring up for discussion: Should there be a padding space between the file name and icons?

My concern is Shift-doubleclicking to select text of the filename without grabbing the icon.

@jarun
Copy link
Owner

jarun commented Aug 12, 2020

And the same on terminator too! My font is monaco. Does that matter?

@jarun
Copy link
Owner

jarun commented Aug 12, 2020

Should there be a padding space between the file name and icons?

Yes, a space would be great.

@jarun
Copy link
Owner

jarun commented Aug 12, 2020

Also forgive the red color I'm not sure why it's red. It wasn't an hour ago.

With NNN_FCOLORS the empty files are shown in red.

@KlzXS
Copy link
Collaborator Author

KlzXS commented Aug 12, 2020

And the same on terminator too! My font is monaco. Does that matter?

For me it works on both st and terminator. xterm and urxvt show a blank box but that's more or less expected.
Your font shouldn't matter as far as I'm aware. I just cloned his repo ran ./build.sh and ./install.sh and it worked.

@jarun
Copy link
Owner

jarun commented Aug 12, 2020

Don;t add the space after the icon BTW. Won't help. The space may get copied.

@KlzXS
Copy link
Collaborator Author

KlzXS commented Aug 12, 2020

Yes, a space would be great.

You want a second space between them?

xfce4-terminal works as well. Must be some issue on your side.

@jarun
Copy link
Owner

jarun commented Aug 12, 2020

@KlzXS can you please share a screenshot with the space added after the icon and let's see how it looks?

src/nnn.c Outdated Show resolved Hide resolved
src/nnn.c Outdated Show resolved Hide resolved
@jarun
Copy link
Owner

jarun commented Aug 12, 2020

I followed the steps here: https://github.com/sebastiencs/icons-in-terminal#installation

@KlzXS
Copy link
Collaborator Author

KlzXS commented Aug 12, 2020

@KlzXS can you please share a screenshot with the space added after the icon and let's see how it looks?

image

@0xACE
Copy link
Collaborator

0xACE commented Aug 12, 2020

Don;t add the space after the icon BTW. Won't help. The space may get copied.

How so? Terminals tends to use space or some other punctuation as a word delimiter.

Unless you have a fancy terminal, Double clicking to select the filename would also copy the icon, which most likely isn't desireable.

You want a second space between them?

No, if there is going to be a space added, I think 1 is enough. Try selecting text in your terminal with doubleclick see what happens. (Note that I hold down Shift in my terminal to select text in nnn)

I would try it on my terminal, but I can't get icons working atm.

@jarun
Copy link
Owner

jarun commented Aug 12, 2020

Terminals tends to use space or some other punctuation as a word delimiter.

Makes sense. Please have a single space. Also please make sure the columns adjustment is done.

@KlzXS
Copy link
Collaborator Author

KlzXS commented Aug 12, 2020

No, if there is going to be a space added, I think 1 is enough. Try selecting text in your terminal with doubleclick see what happens. (Note that I hold down Shift in my terminal to select text in nnn)

One space is added so that the icons don't overlap with the text (some rendering issue or something idk). Another one could be added so that there is a physical space between the icon and text. See screenshot above.

Only the filename is selected. As with any other word.

@KlzXS
Copy link
Collaborator Author

KlzXS commented Aug 12, 2020

Also please make sure the columns adjustment is done.

That's done automatically. You just need to change ICON_PADDING_LEFT/RIGHT in icons.h.
Keeping it as it is then. Single space for no overlap and icon right next to text.

@jarun
Copy link
Owner

jarun commented Aug 12, 2020

@KlzXS what is the content of your ~/.config/fontconfig/conf.d/30-icons.conf ?

@jarun
Copy link
Owner

jarun commented Aug 12, 2020

And which font are you using in your terminal?

@KlzXS
Copy link
Collaborator Author

KlzXS commented Aug 12, 2020

~/.config/fontconfig/conf.d/30-icons.conf :

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  <!-- You are supposed to remove all the lines but the one(s) where the font is used in your terminal -->
  <!-- Only monospaced fonts have been listed here -->
  <!-- If your font isn't in the list, uncomment the next line and write its name -->
  <!-- <alias><family>YOUR_TERMINAL_FONT</family><default><family>icons-in-terminal</family></default></alias> -->
  <alias><family>DejaVu Sans Mono</family><prefer><family>icons-in-terminal</family></prefer></alias>
  <alias><family>mtx</family><prefer><family>icons-in-terminal</family></prefer></alias>
  <alias><family>Nimbus Mono PS</family><prefer><family>icons-in-terminal</family></prefer></alias>
  <alias><family>Noto Color Emoji</family><prefer><family>icons-in-terminal</family></prefer></alias>
  <alias><family>Source Code Pro</family><prefer><family>icons-in-terminal</family></prefer></alias>
  <alias><family>Source Code Pro,Source Code Pro Black</family><prefer><family>icons-in-terminal</family></prefer></alias>
  <alias><family>Source Code Pro,Source Code Pro ExtraLight</family><prefer><family>icons-in-terminal</family></prefer></alias>
  <alias><family>Source Code Pro,Source Code Pro Light</family><prefer><family>icons-in-terminal</family></prefer></alias>
  <alias><family>Source Code Pro,Source Code Pro Medium</family><prefer><family>icons-in-terminal</family></prefer></alias>
  <alias><family>Source Code Pro,Source Code Pro Semibold</family><prefer><family>icons-in-terminal</family></prefer></alias>
  <alias><family>Source Code Variable</family><prefer><family>icons-in-terminal</family></prefer></alias>
  <alias><family>Monospace</family><default><family>icons-in-terminal</family></default></alias>
</fontconfig>

I haven't a slightest idea what any of this is, haven't touched it.

@KlzXS
Copy link
Collaborator Author

KlzXS commented Aug 12, 2020

It should be Liberation Mono.

@jarun
Copy link
Owner

jarun commented Aug 12, 2020

I need these fonts installed. For me it is:

?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  <alias><family>No font found</family><prefer><family>icons-in-terminal</family></prefer></alias>         
</fontconfig>

@KlzXS
Copy link
Collaborator Author

KlzXS commented Aug 12, 2020

I don't think you need all of them. A monospaced font is nice to have either way, I can't work properly with anything else.

@jarun
Copy link
Owner

jarun commented Aug 12, 2020

@KlzXS Which font are you using in your terminal?

@leovilok
Copy link
Collaborator

my other font

I told you I win the ugliest setup contest ...

@jarun
Copy link
Owner

jarun commented Aug 13, 2020

I told you I win the ugliest setup contest ...

And I don't dare to argue ;). But hey, if you are comfortable, all is well.

Anyway we can work on this when icon-specific colors are in. Need to wait for @KlzXS to update.

src/nnn.c Outdated Show resolved Hide resolved
@jarun
Copy link
Owner

jarun commented Aug 15, 2020

@KlzXS please address the comments. You'll have to rebase as I did a minor update to Makefile.

I think we are very near to completion. Once in, I will prepare for the next release.

@KlzXS
Copy link
Collaborator Author

KlzXS commented Aug 15, 2020

Sure thing. I'll send it in later tonight.

Regarding icon colors, it should be a uchar or something else?

@jarun
Copy link
Owner

jarun commented Aug 15, 2020

Regarding icon colors, it should be a uchar or something else?

Yes, we support xterm 256 color, so 1 byte per color.

@KlzXS KlzXS force-pushed the icons branch 3 times, most recently from 58c9bdb to c8d3880 Compare August 16, 2020 00:05
src/nnn.c Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
src/nnn.c Outdated Show resolved Hide resolved
@jarun
Copy link
Owner

jarun commented Aug 16, 2020

I am merging this. Can you please add icons related details in the Wiki?
Please add it as the first section here: https://github.com/jarun/nnn/wiki/Advanced-use-cases

@jarun jarun merged commit a85467d into jarun:master Aug 16, 2020
@jarun
Copy link
Owner

jarun commented Aug 16, 2020

Thank you!

@jarun
Copy link
Owner

jarun commented Aug 16, 2020

We also need an entry to O_ICONS under make options section.

No icons with oldcolor. Small optimizatons
Small refinement for other matching
@chandrahmuki
Copy link

Hi guys ,
i went through all the process multiple times .. but still not seeing anything in nnn when i launch it no icons ? im using kitty and i have Hack as my main font ? did i forgot something ?

thanks for the help !

@KlzXS
Copy link
Collaborator Author

KlzXS commented Sep 7, 2020

The icons are currently setup to work with icons-in-terminal out of the box.
If your font already has glyphs for file icons you don't need to use icons-in-terminal.
But you will have to specify the correct code points for your font (eg. \ue615). You can put them in icons.h in place of the predefined symbols there ("\ue615" in place of FA_FILE, these are just examples use the values that apply for your font). Then recompile the program.

@chandrahmuki
Copy link

chandrahmuki commented Sep 7, 2020

hi ! i don't know man ...really i tried everything nothing is working ..i tried to add the code from hack font in icons.h and recompile doesn't change anything ..icons should appear instantly when you launch nnn right ?
I'm probably very dumb on this one ...another thing maybe where do you define the string ? the Static const struct at line 33 ? with FA_FILE_0 ?

another thing there's no shortcut or anything right to display the icons ? they should be displayed instantly when you launch nnn ? correct ?

thanks again and sorry for my ignorance .. !

@KlzXS
Copy link
Collaborator Author

KlzXS commented Sep 7, 2020

where do you define the string ? the Static const struct at line 33 ? with FA_FILE_0 ?

Yes replace the all-caps symbols with your strings.

Did you compile using make O_ICONS=1? Icons need to be enabled at compile time.

@chandrahmuki
Copy link

i changed the makefile and switch to 1 for ICONS yes

@0xACE
Copy link
Collaborator

0xACE commented Sep 7, 2020

FWIW icons-in-terminal didn't work on my machine so I didn't bother researching further. @chandrahmuki my point is, you will have to get icons-in-termal working first, before you even try it in nnn

@chandrahmuki
Copy link

well icons-on-terminals always worked for me ? i was always able to print all the glyph in my terminal without any problem ?

@0xACE
Copy link
Collaborator

0xACE commented Sep 8, 2020

well icons-on-terminals always worked for me ? i was always able to print all the glyph in my terminal without any problem ?

Are you specifically using this project for rendering icons?

https://github.com/sebastiencs/icons-in-terminal

Otherwise #722 is of interest to you.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants