Hello fellow JMPers,
With text boxes you set the wrap and width pixels and the height of the textbox is automatically set large enough to accommodate the text. For example:
my_narr = "Bacon ipsum dolor amet sirloin short loin meatloaf doner, shoulder swine brisket bacon pig boudin alcatra ham hock chuck hamburger corned beef. Pork chop landjaeger sausage frankfurter biltong doner pork loin ham pastrami fatback sirloin. Brisket prosciutto corned beef short ribs. Ball tip filet mignon shoulder, landjaeger corned beef fatback cow shank venison pork chop bacon meatball bresaola leberkas. Tri-tip short ribs andouille tail prosciutto doner swine ground round meatloaf pancetta boudin.
Brisket beef bacon, landjaeger beef ribs tenderloin alcatra t-bone short ribs venison fatback capicola picanha pig. Salami brisket doner drumstick pork loin shank chicken corned beef short ribs chuck meatball t-bone. Andouille frankfurter rump strip steak landjaeger bacon beef ham hock hamburger flank picanha. Brisket short loin flank hamburger pork belly sausage bresaola doner. Biltong prosciutto jerky, spare ribs porchetta picanha rump pork swine pork loin cupim.";
nw = new window("Test",
tb = text box(my_narr),
);
tb << set wrap(600) << set width(600);
I have some long texts that I put into text edit boxes, because users want to copy/paste portions of the information. However text edit boxes need to set the height using set nlines.
nw = new window("Test",
teb = text edit box(my_narr),
);
teb << set wrap(600) << set width(600) << set nlines(10);
Is there some slick way to calculate the number of lines given a lengthy text? I came up with a way to do it, but it seems clunky. I've attached the code necessary to run this example. There are two functions, get_num_lines and my_parse. I had to write my own parser to handle arbitrarily long delimiters, and two or more occurrences of a delimiter with nothing in between.
nw = new window("Test",
teb = text edit box(my_narr),
);
num_lines = get_num_lines(my_narr, 600);
teb << set wrap(600) << set width(600) << set nlines(num_lines);