Page 4 of 4

Re: TextEditGadgetEx PB 4.60

Posted: Tue Nov 15, 2011 10:45 am
by BjornF
Very nice gadget !

I just noticed a minor bug (I think), on line 565 it says #PB_Canvas_GrabMouse, shouldn't it be #PB_Canvas_ClipMouse ?

all the best / Björn

Re: TextEditGadgetEx PB 4.60

Posted: Tue Nov 15, 2011 8:02 pm
by idle
I don't know maybe the constants been changed,thanks for the heads up
there's still a few bugs in it, it was never really intended to be an editor

Re: TextEditGadgetEx PB 4.60

Posted: Fri Aug 29, 2014 3:30 pm
by Tenaja
idle, have you done anything with this? I just tried it, and on Windows 7 it crashes on line 716 when I hit the Tab key:

Code: Select all

Procedure TextGadgetEx_AddText(*this.TextGadgetEX,mword.s,font=-1,size=12,color=-1,style=0)
	Protected timg,width,height,ct,word.s,a,tf.i,key.s
	
	If ListSize(*this\ltype()) = 0     ; <---- CRASH on Tab key: Invalid Memory Access.

Re: TextEditGadgetEx PB 4.60

Posted: Fri Aug 29, 2014 3:38 pm
by Tenaja
I did not try to truly understand the code, but you had a static var that was never assigned a value, and that was used as a pointer in a call to CanvasCallBack() here:

Code: Select all

CompilerIf  #PB_Compiler_OS = #PB_OS_Windows
	Procedure CanvasCallBack(hwnd,msg,wparam,lparam)
		Static lobj      ; <------ Never initialized -------
		Protected proc,obj,ctrl,*obj.TextGadgetEX
		proc = GetProp_(hwnd,"proc")
		obj = GetProp_(hwnd,"obj")
		*obj = obj
		If msg = #WM_CHAR
			If  wparam > 31   
				TextGadgetEx_AddText(obj,Chr(wparam))
				TextGadgetEx_Output(obj)
			EndIf
		ElseIf msg = #WM_KEYUP
			If wparam = #VK_TAB
				*obj\lstate=1
				TextGadgetEx_AddText(lobj,Chr(wparam)) ; <---was used on these two lines
				TextGadgetEx_Output(lobj)                       ; <--- I replaced them with just obj.
			EndIf
		ElseIf msg = #WM_NCDESTROY
			RemoveProp_(hwnd, "proc")
			RemoveProp_(hwnd, "obj")
		EndIf
		ProcedureReturn CallWindowProc_(proc,hwnd,msg,wparam,lparam) 
	EndProcedure
	
CompilerEndIf
Replacing those two calls using lobj with just obj seemed to make it work.

Re: TextEditGadgetEx PB 4.60

Posted: Fri Aug 29, 2014 7:46 pm
by davido
@idle,

Hadn't seen this before. Very nice.

Runs fine on Window 7 after the a few changes:

Error log:
[19:31:25] [COMPILER] Line 565: Constant not found: #PB_Canvas_GrabMouse. GrabMouse -> ClipMouse
[19:31:41] [COMPILER] Line 652: Comparisons (=, <, >, =< and >=) are only supported with keywords like If, While, Until or within Bool(). -> Added Bool(
[19:32:22] [COMPILER] Line 1161: Constant not found: #PB_Shortcut_Prior. Prior -> PageDown
[19:33:06] [COMPILER] Line 1163: Constant not found: #PB_Shortcut_Next. Prior -> PageUp
[19:33:26] Waiting for executable to start...
[19:33:26] Executable type: Windows - x64 (64bit, Unicode)
[19:33:26] Executable started.
[19:37:34] The Program execution has finished.

Re: TextEditGadgetEx PB 4.60

Posted: Fri Aug 29, 2014 11:06 pm
by idle
Sorry the code is a bit of a Frankenstein it was originally made before we had the canvas gadget
I'm without windows at the moment, I had fixed the callback but apparently didn't post the fix
and the current version I have is to long to post as it has a syntax highlighter half built in.

If you can send me the fixed code I'll edit the post.

Re: TextEditGadgetEx PB 4.60

Posted: Sat Aug 30, 2014 8:45 am
by Bisonte
line 652 in procedure TextGadgetEx_Clear() is a little bit confusing :

Code: Select all

Procedure  TextGadgetEx_Clear(*this.TextGadgetEX)
 
   ForEach *this\glyphs()
       If IsImage(*this\glyphs()\img)
         FreeImage(*this\glyphs()\img)
         *this\glyphs()\img = 0
         *this\glyphs()\ref = 0
       EndIf
    Next   
   
    ClearList(*this\ltype())
       
     AddElement(*this\ltype())
     *this\ltype()\rc\left = *this\MarginLeft
     *this\ltype()\rc\right = *this\MarginRight = *this\MarginLeft+1 ; <<<<<<<<<<<<< ??????? 
     *this\ltype()\rc\bottom = 1
     If *this\cfont\size <> 0
       CopyStructure(*this\cfont,*this\ltype()\font,font)
     EndIf
     AddElement(*this\ltype())
    *this\insert = @*this\ltype()
    TextGadgetEx_Output(*this)
    *this\bedit = 0
  EndProcedure
How can I change that to work ?

Re: TextEditGadgetEx PB 4.60

Posted: Sat Aug 30, 2014 12:54 pm
by yrreti
*this\ltype()\rc\right = *this\MarginRight = *this\MarginLeft+1 ; <<<<<<<<<<<<< ???????

Code: Select all

*this\ltype()\rc\right = *this\MarginRight + *this\MarginLeft+1 ; <<<<<<<<<<<<< common += typo

Re: TextEditGadgetEx PB 4.60

Posted: Sat Aug 30, 2014 3:54 pm
by Tenaja
yrreti wrote:
*this\ltype()\rc\right = *this\MarginRight = *this\MarginLeft+1 ; <<<<<<<<<<<<< ???????

Code: Select all

*this\ltype()\rc\right = *this\MarginRight + *this\MarginLeft+1 ; <<<<<<<<<<<<< common += typo
Funny, I wrapped it in bool() instead; cannot tell a difference in operating. I did not try to debug it.

Re: TextEditGadgetEx PB 4.60

Posted: Sat Aug 30, 2014 11:59 pm
by idle
I updated the code with the last version I had minus the highlighter.
The code is really a dogs bollicks, it was Ok when it was only intended to display text
but adding in editing really messed it up.