Page 2 of 2
Re: A Plain-text only editorGadget?
Posted: Tue Aug 31, 2010 8:27 pm
by rsts
As written, All the items fit in the window. No scoll necessary.
You're ending with a chr(13) which creates a carriage return at the end of the text.
Seems to work fine.
cheers
Re: A Plain-text only editorGadget?
Posted: Tue Aug 31, 2010 10:11 pm
by Nico
Hello,
you never see the last line if it is empty, and impossible to scroll to the end.
you do not have this problem?
Re: A Plain-text only editorGadget?
Posted: Tue Aug 31, 2010 10:33 pm
by RASHAD
Hi
Code: Select all
Texte.s="1"+Chr(13)+"2"+Chr(13)+"3"+Chr(13)+"4"+Chr(13)+"5"+Chr(13)+"6"+Chr(13)+"7"+Chr(13)
If OpenWindow(0, 0, 0, 300, 120, "EditorGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
hWnd = EditorGadget(0, 10, 10, 280, 100)
SetGadgetText(0, "")
SetGadgetText(0,Texte)
SendMessage_(hWnd, #EM_SETTEXTMODE, #TM_PLAINTEXT, 0)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Or
Code: Select all
Texte.s="1"+Chr(13)+"2"+Chr(13)+"3"+Chr(13)+"4"+Chr(13)+"5"+Chr(13)+"6"+Chr(13)+"7"+Chr(13)
If OpenWindow(0, 0, 0, 300, 120, "EditorGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
hWnd = EditorGadget(0, 10, 10, 280, 100)
SendMessage_(hWnd, #EM_SETTEXTMODE, #TM_PLAINTEXT, 0)
SetGadgetText(0, "")
SetGadgetText(0,Texte)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Re: A Plain-text only editorGadget?
Posted: Wed Sep 01, 2010 3:00 pm
by Nico
SendMessage_ (hWnd, EM_SETTEXTMODE #, # TM_PLAINTEXT, 0) does not work in the examples you give.
Indeed, it is possible to paste text in color (RTF)
We must make a SetGadgetText (0, "") just before.

Re: A Plain-text only editorGadget?
Posted: Wed Sep 01, 2010 6:10 pm
by RASHAD
Nico
Both the two examples are OK
Tested with PB 4.5 and XP x86 SP2 and Win 7 x86
For paste color RTF see next URL
http://www.purebasic.fr/english/viewto ... 2&t=43458
Re: A Plain-text only editorGadget?
Posted: Wed Sep 01, 2010 6:15 pm
by srod
Nico is correct Rashad. Your code allows for the pasting of styled text which is what the original code was there to prevent. You need to reorder the code.
Re: A Plain-text only editorGadget?
Posted: Wed Sep 01, 2010 7:06 pm
by RASHAD
In that case we should keep Nico code as it is
Just update
Code: Select all
Texte.s="1"+Chr(13)+"2"+Chr(13)+"3"+Chr(13)+"4"+Chr(13)+"5"+Chr(13)+"6"+Chr(13)+"7"+Chr(13)
To
Code: Select all
Texte.s="1"+Chr(13)+"2"+Chr(13)+"3"+Chr(13)+"4"+Chr(13)+"5"+Chr(13)+"6"+Chr(13)+"7"+Chr(10)+Chr(13)
There will be more 1 blank line but you can scroll to the end
Re: A Plain-text only editorGadget?
Posted: Thu Sep 02, 2010 1:20 pm
by Nico
Yes it works but it's very annoying that scroll.
Thanks
Re: A Plain-text only editorGadget?
Posted: Thu Sep 02, 2010 2:46 pm
by rsts
Hi Nico,
I'm not exactly sure what it is you're attempting to do or what the issue is with the scroll.
Regarding plain text. I believe code has been posted which will make the editor gadget a plain text control.
Is there still some issue regarding plain text? You can set up a callback and capture any "paste" into the editor and only paste plain text yourself, as an alternative.
Regarding the scroll problem. In the Windows world, a "new line" is a CRLF or chr(13) + chr(10), whereas in Unix a chr(10) is sufficient.
Since Windows regards new line as a separator:
"There is also some confusion whether newlines terminate or separate lines. If a newline is considered a separator, there will be no newline after the last line of a file. The general convention on most systems is to add a newline even after the last line, i.e. to treat newline as a line terminator. Some programs have problems processing the last line of a file if it is not newline terminated. Conversely, programs that expect newline to be used as a separator will interpret a final newline as starting a new (empty) line." from Wikipedia.
I believe you can solve the scrolling problem by adhering to the Windows conventions for new lines - i.e. separate new lines with a CR+LF
If you wish to use LF as the separator, add a blank to the last line so it's not empty.
I haven't used a raw windows edit control enough to know if PB is handling this differently than MS but I doubt it since PB is merely employing the MS control.
Does that help at all?
cheers
Re: A Plain-text only editorGadget?
Posted: Fri Sep 03, 2010 11:17 pm
by Nico
I am surprised that you did not have this problem, I decided to use a multiline stringgadget for now.
Thank you for your contribution!