Compare commits
3 Commits
b9ba894cc9
...
ce2b8b39c0
Author | SHA1 | Date | |
---|---|---|---|
ce2b8b39c0 | |||
e57751fe0e | |||
4d6cd247cb |
27
README.adoc
27
README.adoc
@ -50,15 +50,20 @@ automatically.
|
||||
|
||||
Dictionaries
|
||||
------------
|
||||
Unfortunately, this application only really works with specific dictionaries.
|
||||
Word definitions have to be in plain text, separated by newlines.
|
||||
This application is intended for use with specific dictionaries: each line
|
||||
should contain one short word definition. Moreover, the only supported content
|
||||
types are plain text, Pango markup, and XDXF (the visual format works better).
|
||||
|
||||
The `make dicts` command will build some examples from freely available sources.
|
||||
The `make dicts` command will build some examples from freely available sources:
|
||||
|
||||
You may use the included 'transform' tool to convert already existing
|
||||
dictionaries that are almost good as they are, e.g., after stripping XML tags.
|
||||
You might want to fix up the `sametypesequence` of the resulting '.ifo' file
|
||||
afterwards, and run 'dictzip' on the resulting '.dict' file to make it compact.
|
||||
- GNU/FDL Czech-English dictionary
|
||||
- Czech foreign words
|
||||
- Czech WordNet 1.9 PDT (synonyms, hypernyms, hyponyms)
|
||||
|
||||
You can use the included 'transform' tool to convert already existing StarDict
|
||||
dictionaries that are nearly good as they are. Remember that you can change
|
||||
the `sametypesequence` of the resulting '.ifo' file to another format, or run
|
||||
'dictzip' on '.dict' files to make them compact.
|
||||
|
||||
https://mega.co.nz/#!axtD0QRK!sbtBgizksyfkPqKvKEgr8GQ11rsWhtqyRgUUV0B7pwg[CZ <--> EN/DE/PL/RU dictionaries]
|
||||
|
||||
@ -66,12 +71,10 @@ Further Development
|
||||
-------------------
|
||||
While I've been successfully using 'sdtui' for many years now, some work has to
|
||||
be done yet before the software can be considered fit for inclusion in regular
|
||||
Linux and/or BSD distributions.
|
||||
Linux and/or BSD distributions:
|
||||
|
||||
An approximate list of things that need to be resolved is as follows:
|
||||
|
||||
- the tab bar and the text input field don't handle overflows well,
|
||||
- figure out a way to become capable of displaying most StarDict dictionaries.
|
||||
- The tab bar and the text input field don't handle overflows well.
|
||||
- Lacking configuration, standard StarDict locations should be scanned.
|
||||
|
||||
Given the entangledness of this codebase, issues with the file format,
|
||||
and general undesirability of terminal UIs, it might be better to start anew.
|
||||
|
24
src/sdtui.c
24
src/sdtui.c
@ -344,6 +344,26 @@ view_entry_split_add_pango (ViewEntry *ve, const gchar *markup)
|
||||
g_free (text);
|
||||
}
|
||||
|
||||
static void
|
||||
view_entry_split_add_xdxf (ViewEntry *ve, const gchar *xml)
|
||||
{
|
||||
// Trivially filter out all tags we can't quite handle,
|
||||
// then parse the reduced XML as Pango markup--this seems to work well.
|
||||
// Given the nature of our display, also skip keyword elements.
|
||||
GString *filtered = g_string_new ("");
|
||||
while (*xml)
|
||||
{
|
||||
const gchar *p = NULL;
|
||||
if (*xml != '<' || !*(p = xml + 1 + (xml[1] == '/'))
|
||||
|| (strchr ("biu", *p) && p[1] == '>') || !(p = strchr (p, '>')))
|
||||
g_string_append_c (filtered, *xml++);
|
||||
else if (xml[1] != 'k' || xml[2] != '>' || !(xml = strstr (p, "</k>")))
|
||||
xml = ++p;
|
||||
}
|
||||
view_entry_split_add_pango (ve, filtered->str);
|
||||
g_string_free (filtered, TRUE);
|
||||
}
|
||||
|
||||
/// Decomposes a dictionary entry into the format we want.
|
||||
static ViewEntry *
|
||||
view_entry_new (StardictIterator *iterator)
|
||||
@ -372,6 +392,10 @@ view_entry_new (StardictIterator *iterator)
|
||||
view_entry_split_add_pango (ve, field->data);
|
||||
found_anything_displayable = TRUE;
|
||||
break;
|
||||
case STARDICT_FIELD_XDXF:
|
||||
view_entry_split_add_xdxf (ve, field->data);
|
||||
found_anything_displayable = TRUE;
|
||||
break;
|
||||
case STARDICT_FIELD_PHONETIC:
|
||||
g_string_append_printf (word, " /%s/", (const gchar *) field->data);
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user