Page 2 of 7

Re: PBEdit - a Canvas-based Texteditor

Posted: Thu Sep 10, 2020 6:37 pm
by davido
Brilliant!
Thank you for sharing. :D

Re: PBEdit - a Canvas-based Texteditor

Posted: Thu Sep 10, 2020 6:52 pm
by mk-soft
Super :D :D :D

Unfortunately 'WindowVectorOutout()' does not work with macOS (Catalina) anymore.
Solution for Style_LoadFont is to create a dummy image.

Line 3428

Code: Select all

Procedure Style_LoadFont(*te.TE_STRUCT, *font.TE_FONT, fontName.s, fontSize, fontStyle = 0)
		ProcedureReturnIf((*te = #Null) Or (*font = #Null))
		
		Protected c, minTextWidth, image
		
		If IsFont(*font\nr)
			FreeFont(*font\nr)
		EndIf
		
		fontStyle | #PB_Font_HighQuality
		CompilerSelect #PB_Compiler_OS
		  CompilerCase #PB_OS_Windows
		    *font\nr						= LoadFont(#PB_Any, fontName, fontSize / DesktopResolutionY() * 1.0, fontStyle)
		  CompilerCase #PB_OS_MacOS
		    *font\nr						= LoadFont(#PB_Any, fontName, fontSize / DesktopResolutionY() * 1.2, fontStyle)
		  CompilerCase #PB_OS_Linux
		    *font\nr						= LoadFont(#PB_Any, fontName, fontSize / DesktopResolutionY() * 1.0, fontStyle)
		CompilerEndSelect
		
		If IsFont(*font\nr)
			
			*font\style					= fontStyle
			*font\id					= FontID(*font\nr)
			*font\name					= fontName
			*font\size					= fontSize
			
			image = CreateImage(#PB_Any, 32, 32)
			If StartVectorDrawing(ImageVectorOutput(image))
				VectorFont(*font\id)
				
				minTextWidth			= VectorTextWidth(" ")
				*font\height			= VectorTextHeight(" ")
				*te\lineHeight			= *font\height
				
				For c = 0 To 255
					*font\width(c)		= Max(minTextWidth, VectorTextWidth(Chr(c)))
				Next
				*font\width(#TAB)			= minTextWidth
				
				StopVectorDrawing()
			EndIf
			FreeImage(image)
			ProcedureReturn #True
		EndIf
		
		ProcedureReturn #False
	EndProcedure
	

Re: PBEdit - a Canvas-based Texteditor

Posted: Thu Sep 10, 2020 8:42 pm
by Mr.L
Thanks for the kind replies!
I already uploaded a new version with multilanguage support.
J. Baker wrote:At idle, it uses 12% CPU and 64 MB of memory. I have an Intel 1.4 Ghz dual core CPU. Not bad. ;)
I think thats strage - 12% at Idle state is quite high, isn't it?
STARGĂ…TE wrote:How long did you worked on this version?
I have worked quite a long time. Many weeks. Mainly because I didn't plan thoroughly in the beginning. So I had to rewrite large parts of the code over and over again.
When i started I didn't even knew about multicursor editing :lol:
oreopa wrote:Column selection mode like UltraEdit would be a nice addition.
Did you try pressing down the "Alt"-key while selecting code with the mouse. Is that what you mean by "column selection"?
User_Russian wrote:The editor only supports English characters and numbers.
That might be true. Unfortunately I have no clue what to do about it :oops:
infratec wrote:I think horizontal and vertical split are swapped
In the new version they are swapped. I thought horizontal splitting means split the "x-axis" but it could also mean that a horizontal split is made on the y-axis...
Mesa wrote:With windows XP 32, there is something wrong with the pop-up menu.
sorry, I didn't think about the XP users.
The adjustments for the Menutitles can be made in the new "language.cfg" file
mk-soft wrote:Unfortunately 'WindowVectorOutout()' does not work with macOS (Catalina) anymore.
Thanks for the reply. Yes, a dummy image is a nice solution. Also the "multi-OS" part for the fontsize.

Re: PBEdit - a Canvas-based Texteditor

Posted: Fri Sep 11, 2020 1:09 pm
by J. Baker
Mr.L wrote:I think thats strage - 12% at Idle state is quite high, isn't it?
It's most likely the blinking cursor having to redraw itself. Otherwise it would be much lower, if not zero percent. ;)

Re: PBEdit - a Canvas-based Texteditor

Posted: Fri Sep 11, 2020 9:57 pm
by oreopa
Mr.L wrote:
oreopa wrote:Column selection mode like UltraEdit would be a nice addition.
Did you try pressing down the "Alt"-key while selecting code with the mouse. Is that what you mean by "column selection"?
It kind of is, and it kind of isn't. :) I know thats not very helpful. It works nicely in tables that are regularly formatted, but in data with shorter lines, or lines with no data at all, it doesn't - its kind of a visual thing, but also a slightly different functionality thing as well. I think the simplest way to describe it is that top left and bottom right of the selection define a box which is the selection, and the cursor(s) are placed there (right side) and data typed or deleted happens there... even in lines with nothing but a <cr>... the selection is uniformly rectangular... i dunno if thats an accurate description... it's kinda hard to explain the subtle difference... phew...

It's not a big deal really. It's a very nice editor indeed.

EDIT: Redraw takes a paltry 0.45% on my ancient 1st gen i5... and (mega-huge) pasting is surprisingly fast...

Re: PBEdit - a Canvas-based Texteditor

Posted: Sat Sep 12, 2020 11:34 am
by Mr.L
@oreopa:
ah, now i see what you mean. But it would be tough to implement that feature into my editor, i guess.
Right now, in my editor the selection is directly connected to the textlines and you cannot select anything that "is not there".
So, i will keep that feature in mind and maybe one day i come up with a solution :wink:

Re: PBEdit - a Canvas-based Texteditor

Posted: Sat Sep 12, 2020 6:39 pm
by davido
@Mr.L ,

I have two questions:

1. Is there a pure text mode that ignores 'keywords'?
2. Can the background and text colours be changed?

Re: PBEdit - a Canvas-based Texteditor

Posted: Sat Sep 12, 2020 7:03 pm
by Mr.L
davido wrote: 1. Is there a pure text mode that ignores 'keywords'?
2. Can the background and text colours be changed?
yes, if you comment the line (near the end of the code)

Code: Select all

PBEdit_LoadStyle(0, "PB_Style.xml")
keywords, folding and indentation will be ignored.

inside the procedure "_PBEdit_::Editor_New"
you can find the line:

Code: Select all

*te\colors\currentBackground = RGBA( 30,  30,  25, 255)
that's the background color

the default textcolor is defined in the procedure "_PBEdit_::Style_SetDefaultStyle"

Code: Select all

Protected defaultColor = RGBA(155,220,255,255)
Maybe it's better to put all the editor color settings into a seperate file.

Re: PBEdit - a Canvas-based Texteditor

Posted: Sat Sep 12, 2020 7:38 pm
by davido
@Mr.L ,

That was quick!
Thank you. :D

Re: PBEdit - a Canvas-based Texteditor

Posted: Sat Sep 12, 2020 9:03 pm
by oreopa
Mr.L wrote:@oreopa:
ah, now i see what you mean. But it would be tough to implement that feature into my editor, i guess.
Right now, in my editor the selection is directly connected to the textlines and you cannot select anything that "is not there".
So, i will keep that feature in mind and maybe one day i come up with a solution :wink:
Yes. I guessed that. I guess one would need to pad the "offending" lines out with tabs/spaces on the fly somehow.

Thx again, really is a work of art.

Re: PBEdit - a Canvas-based Texteditor

Posted: Sat Sep 12, 2020 10:29 pm
by Mr.L
A new version is online (1.0.2)

Download

added: Settings file "PBEdit.xml"
all editor settings and colors can be changed inside this file.

Re: PBEdit - a Canvas-based Texteditor

Posted: Thu Sep 24, 2020 2:54 pm
by falsam
Whoooo! I love it. Congratulations for this code

Re: PBEdit - a Canvas-based Texteditor

Posted: Sat Sep 26, 2020 8:43 am
by Mesa
You can download the french translation, here:
http://frazier.wood.free.fr/pb/language_FR.cfg

M.

Re: PBEdit - a Canvas-based Texteditor

Posted: Sat Sep 26, 2020 11:37 am
by Mr.L
thank you, Mesa!
I've uploaded a new version (1.0.5 - see first post) that includes your translation!

Re: PBEdit - a Canvas-based Texteditor

Posted: Sat Sep 26, 2020 7:42 pm
by Saki
Hi,
the flickering of the text below, when the mouse is moved, or other, can be removed completely with a trick.

Code: Select all

		Case #PB_Event_Gadget
		  lineNr$="lineNr: " + Str(PBEdit_GetCurrentLineNr(0)) +
		          "  Column: " + Str(PBEdit_GetCurrentColumnNr(0)) +
		          "  (Char: " + Str(PBEdit_GetCurrentCharNr(0)) + ")"
		  If lineNr$<>old_lineNr$
		    StatusBarText(0, 0, lineNr$)
		    old_lineNr$=lineNr$ 
		  EndIf
		  
		  selection$="Selection [" + 
		             Str(PBEdit_GetFirstSelectedLineNr(0)) + ", " + 
		             Str(PBEdit_GetFirstSelectedCharNr(0)) + "] [" + 
		             Str(PBEdit_GetLastSelectedLineNr(0)) + ", " + 
		             Str(PBEdit_GetLastSelectedCharNr(0)) + "]"
		  If selection$<>old_selection$
		    StatusBarText(0, 1, selection$)
		    old_selection$=selection$
		  EndIf
		  
		  If ListSize(*te\cursor())<>old_cursors_changed
		    StatusBarText(0, 2, "Cursors: " + Str(ListSize(*te\cursor())))
		    old_cursors_changed=ListSize(*te\cursor())
		  EndIf
Best Regards Saki