BBC BASIC
« Text Edit »

Welcome Guest. Please Login or Register.
Mar 31st, 2018, 10:46pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Cross-platform BBC BASIC (Windows, Linux x86, Mac OS-X, Android, iOS, Raspberry Pi)
BBC BASIC Resources
BBC BASIC Help Documentation
BBC BASIC for Windows Home Page
BBC BASIC Programmers' Reference
BBC BASIC Beginners' Tutorial
BBC BASIC for SDL 2.0 Home Page
BBC BASIC Discussion Group

« Previous Topic | Next Topic »
Pages: 1 2  Notify Send Topic Print
 veryhotthread  Author  Topic: Text Edit  (Read 399 times)
DDRM
Global Moderator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 36
xx Re: Text Edit
« Reply #10 on: Mar 1st, 2018, 8:07pm »

This link:

http://jonripley.com/bb4w/win32api/viewer/

Appears to be active?

Best wishes,

D
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 803
xx Re: Text Edit
« Reply #11 on: Mar 2nd, 2018, 09:03am »

on Mar 1st, 2018, 8:07pm, DDRM wrote:
This link: Appears to be active?

Amazing. Grab it while you can!

Richard.
User IP Logged

KenDown
New Member
Image


member is offline

Avatar




PM


Posts: 49
xx Re: Text Edit
« Reply #12 on: Mar 2nd, 2018, 4:32pm »

Hooray!

After much head-banging I finally realised why links appeared in your window but not in mine - it was the "Link Window" instead of "RichEdit20"!

So now I have verse numbers appearing as links; so far so great. There are two problems: although by using a flag of &A00044 I have a scroll bar appearing on the right, no amount of clicking or dragging will scroll the window contents.

The second problem is that UTF-8 characters - such as Bulgarian - are not rendered.

I would be grateful for pointers to the solution, assuming that there is a solution!

bibledisp%=FN_createwindow(!bibledlg%,"Link Window","",4,4,230,558,99,&A00044,0)
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 803
xx Re: Text Edit
« Reply #13 on: Mar 2nd, 2018, 4:51pm »

on Mar 2nd, 2018, 4:32pm, KenDown wrote:
I would be grateful for pointers to the solution, assuming that there is a solution!

It's years since I've used a Link Control (I'm not even sure I've ever used one in a real program) and I've forgotten everything I ever knew about them. If it's not scrolling I fear the most likely explanation is that scrolling is not supported. sad

I'm pretty confident that Unicode text should work however. You would of course need to use WINLIB5U or WINLIB5W (depending on whether it's UTF-8 or UTF-16/UCS-2) rather than the plain WINLIB5(A) library, but otherwise I would be surprised if there is a problem.

I wonder, however, why you've seemingly abandoned the Rich Edit control because that does support scrolling (and colouring, which is something else you wanted I believe) and if you can successfully respond to the WM_NOTIFY messages from a Link Control there's no obvious reason why the same technique would not work for a Rich Edit control too.

I was thinking that you would need to use the SUBCLASS library, which is explicitly documented as not working with WM_NOTIFY messages, but the Link Window seems to work without it. I'd actually forgotten (no surprise there!) that I'd modified BB4W so that ON SYS handles WM_NOTIFY messages if you execute a *SYS 1.

Richard.
« Last Edit: Mar 2nd, 2018, 10:18pm by Richard Russell » User IP Logged

KenDown
New Member
Image


member is offline

Avatar




PM


Posts: 49
xx Re: Text Edit
« Reply #14 on: Mar 8th, 2018, 10:28am »

Weyhey! I've got part of it working - the hymn list, which is one hymn per line. Just in case anyone's interested:

ON SYS click%=FNsys(@msg%,@wparam%,@lparam%):RETURN

and then in the main program loop:

REPEAT
CASETRUE OF
WHEN!outlinedlg%>0:REM When the dialog box is open
IF@wparam%=&1000000THEN
!text%=256:SYS"SendMessage",hymnlist%,&C4,0,text%:
SYS"SendMessage",hymnlist%,&C9,-1TOline%
SYS"SetDlgItemText",!outlinedlg%,caret%,hymn$(line%)
ELSE
PROCoutlineclick(click%)
ENDIF
ENDCASE
UNTILFALSE

There is, of course, much else in the REPEAT...UNTIL loop.

I set caret% by clicking on a button beside the edit box into which the hymn will be written. (For some reason clicking on the edit box itself didn't work reliably.) PROCoutlineclick handles all other clicks in that particular dialog box.

Note that the value line% was coming out wrong until I realised that a couple of hymn titles were so long they were wrapping onto the next line. The solution was to change the final digits of the flag in the edit box creation call to &C4 instead of &44.

So thanks, Richard, for pointing me in the right direction. Now I can start battering my brains on the Bible verses!
User IP Logged

KenDown
New Member
Image


member is offline

Avatar




PM


Posts: 49
xx Re: Text Edit
« Reply #15 on: Mar 8th, 2018, 8:06pm »

We make progress!

However I am stymied by a problem that I have noticed before. In RiscOs, if you had a menu that came up over a window and you clicked on a menu item, that was fine. With windows, however, it is as though you had clicked on the underlying window. It usually returns the correct value for the menu item, but it also acts as though you had clicked on the window at that point.

Is there any way round that, please?
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 803
xx Re: Text Edit
« Reply #16 on: Mar 8th, 2018, 8:58pm »

on Mar 8th, 2018, 8:06pm, KenDown wrote:
Is there any way round that, please?

Actually, in Windows, mouse clicks aren't seen by an underlying window, except in special cases when the window itself is transparent. However, if you use the MOUSE statement (or INKEY) you aren't testing for a click, you are testing the state of the mouse buttons directly.

So if you want to avoid seeing mouse clicks on a menu, use the ON MOUSE statement rather than the MOUSE statement. This is preferable anyway, because ON MOUSE will respond to a click however short it is, whereas to guarantee it will be seen by MOUSE you have to hold the button down for a minimum time period.

This really goes back to the earlier discussions in this thread, when you wanted to detect a click on a Rich Edit control. Then you were actually taking advantage of the fact that MOUSE sees the state of the buttons directly, so you could see the click even though it was on the Rich Edit window rather than your program's window.

So, to summarise, MOUSE sees the state of the buttons, irrespective of what window the mouse is over. ON MOUSE responds to a click on BBC BASIC's window, but won't see a click on a different window. ON SYS can see clicks on other windows, if they support that functionality (which fortunately we discovered a Rich Edit control does).

Richard.
« Last Edit: Mar 10th, 2018, 10:44pm by Richard Russell » User IP Logged

KenDown
New Member
Image


member is offline

Avatar




PM


Posts: 49
xx Re: Text Edit
« Reply #17 on: Mar 9th, 2018, 04:16am »

Well, I've got it working - and thanks for all your help. I could not have done it without your patience and guidance.

Mind you, it is a horrible bodge: there are five nested IF...THEN...ENDIFs to test if the correct window is open, the mouse button is 4, the mouse x and the mouse y are in the right place and if nothing else (ie. a menu item) has been clicked on first. I'm sure that RiscOs wasn't nearly so complicated!

Incidentally, you were there at the time: is it true that the WIMP part of RiscOs was written by a games developer?
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 803
xx Re: Text Edit
« Reply #18 on: Mar 10th, 2018, 10:47pm »

on Mar 9th, 2018, 04:16am, KenDown wrote:
Incidentally, you were there at the time: is it true that the WIMP part of RiscOs was written by a games developer?

I don't know who that question was directed to. Not to me, I hope, since I know nothing about RISC OS (and I certainly wasn't "there at the time").

Richard.
User IP Logged

KenDown
New Member
Image


member is offline

Avatar




PM


Posts: 49
xx Re: Text Edit
« Reply #19 on: Mar 11th, 2018, 05:06am »

My apologies. I thought you had been involved in the Archimedes.
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 803
xx Re: Text Edit
« Reply #20 on: Mar 11th, 2018, 10:31am »

on Mar 11th, 2018, 05:06am, KenDown wrote:
I thought you had been involved in the Archimedes.

No. My involvement with the project ended at the very beginning of Acorn's development of what became the Archimedes. I had some exchanges with Sophie over the enhancements she proposed to BBC BASIC (for example I was responsible for insisting that WHILE...ENDWHILE loops be nestable, which they weren't in her proposal), but I was 'off the case' before RISC OS itself came into being and I've never owned or used an Archimedes, RISC PC or any other Acorn ARM-based device.

You can detect some of this history in 'BBC BASIC for Windows' which has good compatibility with the old 6502 BBC BASIC, implements the new language constructs (like WHILE..ENDWHILE and CASE..ENDCASE) accurately, but has poor compatibility with the Archimedes and RISC OS. For example the MODE and SOUND statements, and the TINT function, work quite differently from those in Sophie's ARM BASIC.

Richard.
User IP Logged

KenDown
New Member
Image


member is offline

Avatar




PM


Posts: 49
xx Re: Text Edit
« Reply #21 on: Mar 11th, 2018, 4:58pm »

Ah. I've had the original Archimedes and a RiscOS. Especially in RiscOS the WIMP and the facilities it offered a programmer were - in my opinion - far superior to Bill Gates' offering.

Oh well.

Now, getting back on-topic: I've got this thing working just fine: click on a verse and it gets inserted; select some text and just the selected text gets inserted. Yippee!

(I'm using the repeated subtractions method to find the correct array element pointed to by the EM_ call, as discussed earlier.)

Then I opened up the Hungarian Bible and it has all gone to pot. The problem, I suspect, is the LEN statement. Is that fully UTF-8 compatible? Is there some quirk in the text editor which returns the wrong value with UTF-8 text?

Any suggestions would be gratefully received.
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 803
xx Re: Text Edit
« Reply #22 on: Mar 11th, 2018, 5:41pm »

on Mar 11th, 2018, 4:58pm, KenDown wrote:
is the LEN statement. Is that fully UTF-8 compatible?

It depends what you mean by "compatible". LEN will of course work with UTF-8 strings the same as any other, but (by design) it returns the number of bytes in the string, not the number of characters. Given that LEN is commonly used to return the length of binary data (e.g. a bitmap stored in a string) that's how it should be, but it may not be what you want.

To get the number of characters in a UTF-8 string you could call the MultiByteToWideChar API, or you may find it easier to code it yourself in BASIC (if it's fast enough for your needs).

Richard.
User IP Logged

KenDown
New Member
Image


member is offline

Avatar




PM


Posts: 49
xx Re: Text Edit
« Reply #23 on: Mar 11th, 2018, 7:10pm »

The question, of course, is which does Windows return from the EM_GETLINE function - bytes or characters? I'm guessing it is characters, as clicking on verse 16 caused verse 10 to be selected!

As you say, I might have to go down the WideChar route (I already have the routine incorporated in the program, so that won't be too difficult).

Thanks.
User IP Logged

KenDown
New Member
Image


member is offline

Avatar




PM


Posts: 49
xx Re: Text Edit
« Reply #24 on: Mar 12th, 2018, 04:09am »

Hmmmm. Famous last words!

FNulen was not too difficult, but the rest of the routine falls flat. http://bb4w.wikispaces.com/Counting+the+characters+in+a+Unicode+string mentions that WIDTH, TAB(x) and COUNT don't work with UTF-8, but you need to add that MID$() and LEFT$() (and, I presume, RIGHT$()) don't work either.

The trouble is that I don't see an easy alternative to MID$. I presume that extracting half a UTF character is not terribly useful!
User IP Logged

Pages: 1 2  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls