* text wrap

Writing and using plugins for Version 5 and above.
User avatar
ColeValleyGirl
Megastar
Posts: 2945
Joined: 28 Dec 2005 22:02
Family Historian: V7
Location: Cirencester, Gloucestershire
Contact:

Re: text wrap

Post by ColeValleyGirl » 06 Jun 2021 12:40

Mark1834 wrote:
06 Jun 2021 12:20
We’ve come a long way from the original question of how to parse a text string... ;).
Agreed.

And I also agree that interpreting some documentation needs nous; but for the libraries in question it's pretty good as long as you have a good grounding in Lua and Lua libraries, and understand the structure of the documentation, and that a readme file is probably all the documentation. (We're in open source land, after all)

If you haven't all of the above yes, it takes some learning if you aren't willing to simply follow trusted advice.

All of us 'super-users' started off following trusted advice for what seemed like magic, and only later going beyond the confines of see-this-do-this.
only a small subset of that subset would go beyond the standard libraries
These are 'standard' libraries made available for FH plugin coders.

Ron wants to see/understand the code of any library he uses, rather than trust advice -- fair enough, but it means he probably won't use any library to make his life easier -- fine, but I don't think he should expect anyone to help him debug code that provides functionality which is available in a library. I appreciate that he wasn't originally asking for such advice but I was hoping I could help him to simplify his code. Never again.

avatar
Mark1834
Megastar
Posts: 798
Joined: 27 Oct 2017 19:33
Family Historian: V7
Location: South Cheshire, UK

Re: text wrap

Post by Mark1834 » 06 Jun 2021 13:52

Yes, it’s a pity the “super user” cohort is so small. I can only think of about half a dozen worldwide, and probably only half of those are regular responders to user questions here.
Mark Draper

User avatar
ColeValleyGirl
Megastar
Posts: 2945
Joined: 28 Dec 2005 22:02
Family Historian: V7
Location: Cirencester, Gloucestershire
Contact:

Re: text wrap

Post by ColeValleyGirl » 06 Jun 2021 14:10

Mark1834 wrote:
06 Jun 2021 13:52
probably only half of those are regular responders to user questions here.
A proportion that is likely to diminish if their advice isn't valued.

I wish Ron well -- he's trying to do very complicated stuff, if only for his own benefit, but life is too short to repeatedly point him to resources he doesn't use. I'm aware of the underlying reasons why he might not do so, but that doesn't make me more likely to advise him when he shows such disrespect for others:
where is the code? if its only binaries, and since I don't know good old Steve-o, we are at the
end of any discussion of using this scrap, because it looks flaky to me.

User avatar
Ron Melby
Megastar
Posts: 732
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: text wrap

Post by Ron Melby » 06 Jun 2021 15:32

You are not a super user Helen, and your 'advice' has always been singularly unhelpful. I bet you dont get told to read the documentation by Scuri when you ask a question, say for instance; regarding themes, because he knows his documentation is unintelligible and sparse, and he just whips out a concrete example when he has time and/or points you to the exact place and steps in his docs about how to get your job done. Nor does he throw you off his list for asking what is to him, an obvious question you should know. Because he wants you to use his stuff, not make it miserable.

I read it, it is unusable (redacted) . Unfortunately, we are all stuck in this play language called Lua.

You do advanced stuff and you ask more experienced users for advice, maybe you take some guff somewhere time to time, but I would posit you have no desire to have someone pontificating about something that has nothing intelligible contained in it when I asked WHERE is UTF8.len, and how do you use it? and the reply is if you read the documentation it says it is in the readme, insuring that you dont explain, its not really in the readme, its in links that are in the readme, that do not appear to be somehow related, and the UTF8.len is in the dll in compat53, nothing you can see without disassembly. OOPS--- (sorry admin), I am not as advanced as you and I can answer the question now, after Mike answered the (understood) question about the links in the readme. I now know that the bloat of the library is not necessary for my purposes to get something I already have in my STANDARD LIBRARIES, further degrading my performance and encroaching on my permanent tables. I appreciate that you have worked hard on your stuff to make it available, but I can do all this in readable format without a steep learning curve that gains me nothing, just because fh is continually behind the 8 ball.
FH V.6.2.7 Win 10 64 bit

User avatar
ColeValleyGirl
Megastar
Posts: 2945
Joined: 28 Dec 2005 22:02
Family Historian: V7
Location: Cirencester, Gloucestershire
Contact:

Re: text wrap

Post by ColeValleyGirl » 06 Jun 2021 16:19

Ron, your post once again demonstrates that you have no respect for people, in breach of: ucp.php?mode=terms. I'm not throwing you off the list, but I am asking you to show respect for others both on and off list.

I've never thought I'm a super-user, hence putting it in quotes; and I've never been too proud to ask for help, and more importantly to follow it to the letter when I receive it (including carefully reading any resource I'm directed to) before complaining about it. I also take care to indicate that I have already read the documentation: pace https://stackoverflow.com/questions/678 ... -attribute. (a tip: I recommend you do not try asking your questions there -- the community is a lot less tolerant than this one, and you will not find it a comfortable place to ask).

Using a library is not advanced; it adds extra functions within a Lua environment which you then invoke in the normal way; I haven't observed that you have any problems calling your own functions or ones made available by Lua, so a library just extends what's available, often with less overhead. (And the documentation for library function calls is usually as sparse as that for Lua function calls). You mention your own STANDARD LIBRARIES, so you are not unfamiliar with the concept.

If you find my advice unhelpful, I'm sorry; I provided a simple "concrete example" of the exact lua statements you should use to access the utf8.len function when you indicated that you didn't know how to proceed, so that a simple copy and paste would do the job you needed. I acknowledged (in my response to Mark) that much of the documentation assumes you know the basics, hence I gave you the exact code you needed to make progress. It was, however, Mike that pointed you to the documentation; I pointed you to the code that you said you wanted to see.

I will now disengage, because the dialog is unproductive. As I have said before, I wish you well in whatever you're trying to achieve.

avatar
Mark1834
Megastar
Posts: 798
Joined: 27 Oct 2017 19:33
Family Historian: V7
Location: South Cheshire, UK

Re: text wrap

Post by Mark1834 » 06 Jun 2021 16:25

Ron - simple question - your post count as of right now is 726. In how many of those have you offered constructive advice to other users, or do you just take and complain...?

The forum works because expert users are so generous with their time to help others.
Mark Draper

User avatar
Ron Melby
Megastar
Posts: 732
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: text wrap

Post by Ron Melby » 06 Jun 2021 17:50

Look it up, its documented. I help where I can. Not being terribly advanced, it often goes to naught. Some help is on the FB group, some here.

How about you, what's your gadfly count?
FH V.6.2.7 Win 10 64 bit

User avatar
Ron Melby
Megastar
Posts: 732
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: text wrap

Post by Ron Melby » 06 Jun 2021 18:12

you threw me off your lua list on stackoverflow for asking my first question there, a simple and on topic question, respectfully. not a hello, goodbye, kma or anything.

I don't think you have cause to make the pretense of 'respecting'.

Yeah, let's drop it, pl and compat53 simply do not do the job for me or simplify anything.
Never again.
FH V.6.2.7 Win 10 64 bit

User avatar
Ron Melby
Megastar
Posts: 732
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: text wrap

Post by Ron Melby » 06 Jun 2021 18:23

function WRAP(str, plen)
-- str = string
-- plen = maximum parse length
plen = plen or 80

str = (tostring(trim(str)):gsub('\t', ' '):gsub('\n', ' ')) or ''
if UTF8len(str) <= plen then
return str
end

local wrap = {}
local len = plen
repeat
local line = str:sub(1, len)
-- Next text line
if #str > plen then
len = line:find('([^ ]-)$') - 1
-- Find trailing non-spaces
if len <= 0 then len = plen end
line = str:sub(1, len)
end
-- Save wrap line
wrap[#wrap + 1] = line
-- set str offset to begin of tail text > plen
str = str:sub(len + 1)
len = plen
until #str == 0

local txt = ''
for key, val in ipairs(wrap) do
txt = string.format('%s%s\n', txt, val)
end
return txt
end -- fn WRAP

mike, I simplified it somewhat because the proportional semi-justified was not working out because of newlines in my notes scattered all over from the early days when I thought what showed in the fh window was wysiwyg.
after the string 'slider is reset to start of tail
@ str = str:sub(len + 1)

I had to reset len to full plen
len = plen
otherwise I was getting a dwindling len at every tail slider reset

abcd
abc
ab
a

for very long sections of text.
I will revisit the proportional division of line lenghts later.
I still like the idea, but more pressing matters.
Thanks.
Easy when you look at it, but I was proceeding from some confused assumptions at the outset, like trying to figure from the reverse and so on.
FH V.6.2.7 Win 10 64 bit

User avatar
ColeValleyGirl
Megastar
Posts: 2945
Joined: 28 Dec 2005 22:02
Family Historian: V7
Location: Cirencester, Gloucestershire
Contact:

Re: text wrap

Post by ColeValleyGirl » 06 Jun 2021 18:24

Ron Melby wrote:
06 Jun 2021 18:12
you threw me off your lua list on stackoverflow for asking my first question there, a simple and on topic question, respectfully. not a hello, goodbye, kma or anything.
I don't moderate StackOverflow. I moderate Genealogy.StackExchange. They are not the same thing.

User avatar
Ron Melby
Megastar
Posts: 732
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: text wrap

Post by Ron Melby » 06 Jun 2021 18:26

it said you removed me from that list. and wiped out my question.

doesnt matter, on to more issues.

thanks.
FH V.6.2.7 Win 10 64 bit

Post Reply