Dushistov / sdcv

https://dushistov.github.io/sdcv/
GNU General Public License v2.0
300 stars 44 forks source link

Color option does not work #50

Closed nivaca closed 5 years ago

nivaca commented 5 years ago

The --color option is not working. It only shows color on the dictionary title, but not on the entries.

screenshot_20190112_122623

(Compare my output with that of another user here: https://github.com/Dushistov/sdcv/issues/46)

I'm running latest version of sdcv on Manjaro Linux KDE. I tried other terminal emulators besides Konsole, with the same results.

Dushistov commented 5 years ago

The color output depend on dictionary. It is like Microsoft Word document, If no one has marked the words or phrases in bold, then the whole text will be plain text.

nivaca commented 5 years ago

Yes... you're right. I tried it with the other user's dictionary and it produced colors. Thanks!

maxigaz commented 4 years ago

@Dushistov Could you give me some pointers on how to edit a dictionary file to make certain elements colourful?

After some online research, I’ve learned how to convert dictionary files to .txt files using PyGlossary (or make my own), edit them, then convert them to .ifo files so that they can be opened in sdcv. What I still don’t know is what tags need to be used for formatting.

In the man page of sdcv, I’ve found that --color refers to “ANSI escape codes”. I assume they are for passing info to the terminal emulator, so I don’t have to use them when editing the dictionary files, right? (I’ve already tried, just in case, but it doesn’t work.)

I’ve also tried opening various dictionaries from http://download.huzheng.org/dict.org/ in sdcv without editing or converting them, but all of them are displayed with a simple, monochrome format. Maybe I picked the “wrong” ones?

Dushistov commented 4 years ago

@maxigaz

To see color you need "-c" or "--color" option on sdcv side, and special sametypesequence on the dictionary side. For example:

StarDict's dict ifo file
version=2.4.2
wordcount=11220
idxfilesize=145047
bookname=Combined Abbreviation Dictionary(En-En)
date=2006.04.09
sametypesequence=x

as you see this dictionary contains sametypesequence equal to x, x mean xdxf format, also p - pango supported.

And it is useless to edit .ifo file and change sametypesequence to x or p. It's like changing the title of a book and hoping that its content changes too.

Your dictionary's articles should be properly formatted, and software that you use to create stardict dictionaries should be able to parse this format. Try to search xdxf formatted dictionaries and makedict program that can convert xdxf to stardict format.

maxigaz commented 4 years ago

Thank you for the explanation!

What I had in mind is editing existing StarDict dictionaries so that they have markup with colours of my choice. At first glance at various resources about XDXF, I think it would be way too much work for me to achieve what I want with this format.

When I look up Pango, I can find some documentation like on this page, but not examples of Pango used in dictionaries. What would I need to do if I chose this format instead?

Dushistov commented 4 years ago

I can find some documentation like on this page,

Yes, pango as simple as described on this page.

What would I need to do if I chose this format instead?

Have no idea. I usually convert stardict to xdxf format via https://github.com/Dushistov/xdxf_makedict , and edit xml file in text editor, and then convert xdxf to stardict back. I have no idea about what software support pango format.