[sword-devel] Getting entry by key for a lexicon module.

David "Judah's Shadow" Blue yudahsshadow at gmx.com
Mon Jan 3 16:38:00 EST 2022


On Monday, January 3, 2022 2:21:41 PM EST Troy A. Griffitts wrote:
> Hi David. You should skip the attempt to parse a verse list. Something
> simple like:
>
> module->setKeyText("Moses");
> SWBuf entryBody = module->renderText();
> SWBuf entryKey = module->getKeyText();

Ah yes, this is what I was looking for. I was using the verse list mostly
because I was shoving all lookups through the same code. I'd begin splitting
out the lexicon code as soon as I saw that it didn't work as intended, I just
didn't know how to reference the key.

> Notice the renderText call before the getKeyText call. renderText will
> "snap" the requested key to the closest entry in the module. If you swap
> the order, the getKeyText will simply return whatever you set, which
> isn't too useful.

Yes. I was doing it in the order I was with the Bible/Commentary stuff so my
display would be of the "key name" "key text" format.

> It's up to you to determine if the snapped entry is of use to your user
> if it is not exactly what you requested. In my frontends, I usually snap
> to the closest entry and then -- the module a couple times and then loop
> over 5 entries, which results in showing the snapped entry and 2 entries
> before and after, and I usually show this as the user types, so they can
> visually see the nearest entries so far, allowing them to navigate to
> their desired entry or see that nothing matches very well. Here is an
> example:

I think, at least at this stage in BIBISH development, I will keep it to the
nearest key only, since screen realestate is potentially at a premium. I have
basically no way of being assured of a minimum terminal size. I'll keep
showing the one before and the one after in the back of my mind though, for
the future. Given my interface choices there is no navigating around, so I'll
have to get creative if I want to do something like that.

> Hope this is helpful.

Yes, most helpful.




More information about the sword-devel mailing list