Compare commits

..

3 Commits

Author SHA1 Message Date
ce2b8b39c0
Update README
We're not that all that far away from a stable version.
2021-10-11 02:46:56 +02:00
e57751fe0e
sdtui: skip keywords in XDXF 2021-10-11 02:43:34 +02:00
4d6cd247cb
sdtui: implement elementary XDXF display
We're lacking word wrapping, but it's more or less usable.
2021-10-11 02:43:30 +02:00
2 changed files with 39 additions and 12 deletions

View File

@ -50,15 +50,20 @@ automatically.
Dictionaries Dictionaries
------------ ------------
Unfortunately, this application only really works with specific dictionaries. This application is intended for use with specific dictionaries: each line
Word definitions have to be in plain text, separated by newlines. 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 - GNU/FDL Czech-English dictionary
dictionaries that are almost good as they are, e.g., after stripping XML tags. - Czech foreign words
You might want to fix up the `sametypesequence` of the resulting '.ifo' file - Czech WordNet 1.9 PDT (synonyms, hypernyms, hyponyms)
afterwards, and run 'dictzip' on the resulting '.dict' file to make it compact.
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] 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 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 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.
- Lacking configuration, standard StarDict locations should be scanned.
- 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.
Given the entangledness of this codebase, issues with the file format, Given the entangledness of this codebase, issues with the file format,
and general undesirability of terminal UIs, it might be better to start anew. and general undesirability of terminal UIs, it might be better to start anew.

View File

@ -344,6 +344,26 @@ view_entry_split_add_pango (ViewEntry *ve, const gchar *markup)
g_free (text); 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. /// Decomposes a dictionary entry into the format we want.
static ViewEntry * static ViewEntry *
view_entry_new (StardictIterator *iterator) view_entry_new (StardictIterator *iterator)
@ -372,6 +392,10 @@ view_entry_new (StardictIterator *iterator)
view_entry_split_add_pango (ve, field->data); view_entry_split_add_pango (ve, field->data);
found_anything_displayable = TRUE; found_anything_displayable = TRUE;
break; break;
case STARDICT_FIELD_XDXF:
view_entry_split_add_xdxf (ve, field->data);
found_anything_displayable = TRUE;
break;
case STARDICT_FIELD_PHONETIC: case STARDICT_FIELD_PHONETIC:
g_string_append_printf (word, " /%s/", (const gchar *) field->data); g_string_append_printf (word, " /%s/", (const gchar *) field->data);
break; break;