Multiple new lines in user defined flashcards

sopsku

秀才
Perhaps this the flashcard exchange thread but hope to reach a larger audience here.

Is there a way to introduce new lines in user generated definitions so that difference "meanings" can be numbered and start on new lines (i.e. formatted line the cards generated from dictionary entries)?
 

Shun

状元
Hi sopsku,

yes, there are a few Unicode codes Pleco 3.2 currently uses for that. In the long run, they will be replaced by a more modern format, though.

------------- (Copied from a post by @alex_hk90) ---------------

Pleco dictionary formatting special codes (unofficial, subject to change) [private use Unicode]:
---
EAB1 = new line
EAB2/EAB3 = bold
EAB4/EAB5 = italic
EAB8/EABB = "copy-whatever's-in-this-to-the-Input-Field hyperlinks"
coloured text:
"EAC1 followed by two characters with the highest-order bit 1 and the lowest-order 12 bits representing the first/second halves of a 24-bit RGB color value to start the range, EAC2 to end. So to render a character in green, for example, you'd want EAC1 800F 8F00, then the character, then EAC2."
---
UTF-8: U+EAB1 = '\xee\xaa\xb1'

------------------------------------------------------------------

The newline can also be copied and pasted from here (without the "<>"): <>

If you edit a user dictionary entry from within Pleco, you can enter regular newlines, but if you were to export them, they would be converted to spaces. You need this special newline character especially if you import and export, or if you prepare a user dictionary from a Mac/PC and import it into Pleco afterwards.

Hope this helps,

Shun
 

mikelove

皇帝
Staff member
Well yeah, it was never intended to be something for users to work with. (Or us, directly at least - it’s spat out by our database encoder) Back on Palm OS it was a big performance win to get formatting data from a single character rather than a whole long tag.
 

pdwalker

状元
Understood. It's not a criticism, and yeah, you didn't intend users to be poking around this stuff.

The explanation is interesting though. Thanks!
 

pdwalker

状元
Hi Mike,

Sorry to bother you with asking for support for an unsupported feature, but I'm having a little trouble getting getting the colors to work based on what I think I've understood from the above.

I've written a program to take a source xml file defining the colors and convert it into a text file suitable for importing into a user dictionary.

From what I understand - if the text file is a UTF8 file with the following unicode character sequences, the colors will render in IOS pleco (ignore spaces - only there for readability):
EAC1 XXXX TEXT EAC2

Where XXXX is the encoded RGB values of the color you want TEXT to appear.

My test source file contains 8 colors, and I believe I have encoded them correctly. The following is raw dump of my calculations for the colors
- first is the RGB values
- then those RGB values converted into binary
- then those RGB values broken into 2 12 bit binary strings, with the top bit set to 1 according to what I understand of the encoding described above.
- then those encoded values converted back into hex
Code:
RRGGBB   rrrrrrrr gggggggg bbbbbbbb       aaaaaaaaaaaa     bbbbbbbbbbbb   HexA HexB   Color
------   -------- -------- --------   ---------------- ----------------   ---- ----   -------
000000 / 00000000 00000000 00000000 / 1000000000000000 1000000000000000 / 8000 8000 / Black
FFFFFF / 11111111 11111111 11111111 / 1000111111111111 1000111111111111 / 8fff 8fff / White
FF0000 / 11111111 00000000 00000000 / 1000111111110000 1000000000000000 / 8ff0 8000 / Red
00FF00 / 00000000 11111111 00000000 / 1000000000001111 1000111100000000 / 800f 8f00 / Green
0000FF / 00000000 00000000 11111111 / 1000000000000000 1000000011111111 / 8000 80ff / Blue
00FFFF / 00000000 11111111 11111111 / 1000000000001111 1000111111111111 / 800f 8fff / Cyan
FFFF00 / 11111111 11111111 00000000 / 1000111111111111 1000111100000000 / 8fff 8f00 / Yellow
FF00FF / 11111111 00000000 11111111 / 1000111111110000 1000000011111111 / 8ff0 80ff / Magenta

So, I'd expect that to encode for Yellow, the unicode sequence would be:
EAC1 8FF0 80FF YELLOW EAC2

When I import my text file (attached) with those unicode sequences, the yellow doesn't appear.

I do get some colors - black appears correct. There is a green. Cyan appears as a powder blue and the rest don't appear.

Can you see anything obvious that I'm doing wrong? Any advice or pointers would be greatly appreciated.
 

Attachments

  • colors-v3.txt
    426 bytes · Views: 432

mikelove

皇帝
Staff member
On Android it's 4 codes, not 2; should be in range EC00-ECFF, last 8 bits of each get aggregated into a 32-bit code.
 

Sonntag

Member
To have different colors in a user dictionary would be nice. As the (iOS) examples here don't seem to work with Android: Can somebody explane how to build the color codes for Android?
 

Cameroon

探花
Turning time machine mode on... :)
To have different colors in a user dictionary would be nice. As the (iOS) examples here don't seem to work with Android: Can somebody explane how to build the color codes for Android?
I think that colorcodes are identical for iOS and Android as it's Pleco internals in action.
But I also don't get the math of the colorcodes transformation.

mikelove
I know it's far beyond support scope, but can you please explain how to calculate color codes for Pleco importing user dicts from .txt?
Say, I have hex code #007af4 (looks good in both day/night mode, is close to Pleco's own font highlighting in nightmode, and it isn't used in my own tone colorcoding scheme too :cool:), how do i need to get the right number XXXX for Pleco (for EAC1 XXXX TEXT EAC2 formula)?
 

mikelove

皇帝
Staff member
Android and iOS use different numeric encoding systems, actually, so they wouldn't work the same between them. For iOS it's:

"EAC1 followed by two characters with the highest-order bit 1 and the lowest-order 12 bits representing the first/second halves of a 24-bit RGB color value to start the range, EAC2 to end. So to render a character in green, for example, you'd want EAC1 800F 8F00, then the character, then EAC2."

But I'd really advise against spending any time on this one since we're not planning to migrate anything but a few basic EA** codes from user dictionaries in 4.0 (probably just bold + newlines); any work you do on this now will be totally wasted once that's out.
 

Cameroon

探花
You must have a spare brain to keep all these in mind (or sooner that's me using only part of own neurons)

Thanks for great news, but even current system is still pretty usable (and authentic), imagine how cool it was back in 00's. Are there any working Palm OS device with Pleco onboard? I'd wish to hold this in hands. Back then, if I had seen it, it would have been a total shock for me))

Anyway, can you just point me to this #007af4 specific color's Pleco Android inner color code for user dicts? If anything changes, I'd just find&replace, it's no big deal to update the source txt once Pleco's formatting upgrades.
 

Cameroon

探花
I input 80078AF4colortext (no spaces, first  being EAC1 and second EAC2) and got this:
1639765154864.png

what am I doing wrong? I feel I'm already a pair of symbols away from the correct syntax.
all the rest is working fine! (italic bold newline even lookup links)
 

mikelove

皇帝
Staff member
These are custom code points - not characters, you have to use a tool that lets you enter a character by code number. Also, the fact that you're seeing the first 4 characters cut off suggests that you're on Android rather than iOS (sorry for my confusion), in which case this wouldn't work anyway and you'd instead want to do EAC1 EC00 EC00 EC7A ECF4.

Again, it's a terrible system and we're going to nuke it in 4.0 anyway so I really wouldn't waste any time on it.
 

Cameroon

探花
Thank you so much, I finally got how to make it work.
Nice system, though a little complicated, but it makes things even cooler feeling like being a (bit of a) programmer )) I wouldn't be so happy now if it was just boring html ))
Thanks again!
 
Top