Page 1 of 7

PBEdit - a Canvas-based Texteditor

Posted: Wed Sep 09, 2020 10:06 pm
by Mr.L
a canvas-based Texteditor - PureBasic only - no external libraries

https://github.com/MR-L-PB/PBEdit

Features
  • Basic editing
  • Mouse support
  • Multicursor
  • Split view (needs improvement when resizing)
  • Syntax highlighting
  • Indentation (none, block, automatic)
  • Autocomplete
  • Folding
  • Case correction
  • Linenumbers
  • "real" tabs or spaces
  • Undo / Redo
  • Drag & Drop
  • Find / Replace Dialog (Regular Expressions supported)
  • Bookmarks
  • Zooming
  • Repeated selections
  • Horizontal / Vertical Scrollbars (optional)
  • Customizable (via xml)
  • DPI aware - check compiler option!
v1.0.1
  • added: multilanguage support (language.cfg file)
v1.0.2
  • added: settings file (PBEdit.xml)
v1.0.3
  • a few bugs fixed
v1.0.4
  • fixed: bug in horizontal scroll (last chars of long textline not visible)
    bug when inserting text with multiple cursors
    missing colors in settings.xml
    beautify procedure removed indentation when in block-mode
  • changed: redraw of cursor only if needed (avoid flickering)
    default style is black/white
    tokenizing and styling simplified
  • added: enhanced character table (use all 65535 characters instead of only 255)
    if needed, set #TE_CharRange to 65536
v1.0.5
  • changed: the cursor now has its own timer and the scroll timer is only activated if needed
  • added: french translation (thx, Mesa!)
v1.0.6
  • fixed: a few scrolling related issues
  • changed: removed the "ID" Parameter from the Procedure "Editor_New". The return value now is a pointer to the TE_STRUCT
    (not the canvas ID anymore)
  • added: PostEvent to signal cursor changes (#TE_Event_Cursor) or selection changes (#TE_Event_Selection)
v1.0.7
  • fixed: wrong filename of default languageFile
  • fixed: faulty line continuation
  • fixed: autocomplete not showing strings starting with # or * (if flag "enableDictionary" is set to true)
  • fixed: syntax highlight issues
  • fixed: indentation lines drawn multiple times
  • added: flag "enableAutoClosingBracket": enable / disable adding of closing brackets
  • added: flag "enableZooming": enable / disable zooming
  • added: Ctrl+Tab - cycle through views
v1.0.8
  • fixed: bug in Procedure Selection_Move that led to adding of blank lines and messed with the undo function
  • fixed: multicursor with overwrite-mode didn't work properly with multiple cursors set in same textline
  • fixed: bug in display of the AutoComplete list
  • changed: the new AutoComplete list is drawn directly on the canvas (no separate Window and ListViewGadget anymore)
v1.0.9
  • fixed: scrolling after a codeblock is collapsed
  • fixed: typo (#TE_Redraw_ChangedLined to #TE_Redraw_ChangedLines)
  • fixed: in find/replace dialog: flags #TE_Find_NoComments and #TE_Find_NoStrings not working
  • fixed: indentation bug (indentation of keywords inside comments, strings etc.)
  • fixed: scollbar bug (interaction between horizontal and vertical scrollbar didn't work properly)
  • added: PBEdit_IsGadget(ID): test if this ID is valid
  • added: PBEdit_FreeGadget(ID): remove editor and free used resources
  • added: in PBEdit_SetSelection: if LineNr < 1 clear selection
  • added: PBEdit_SelectionCharCount(ID): return the number of selected characters
  • added: Folding_ToggleAll(*te.TE_STRUCT): toggle all folds
  • added: flag "enableReadOnly": if set to true, the editor is read only (no changes of the text allowed)
  • changed: renamed PBEdit_GetFirstSelectedLineNr to PBEdit_GetCursorLineNr
  • changed: renamed PBEdit_GetFirstSelectedCharNr to PBEdit_GetCursorCharNr
  • changed: renamed PBEdit_GetLastSelectedLineNr to PBEdit_GetSelectionLineNr
  • changed: renamed PBEdit_GetLastSelectedCharNr to PBEdit_GetSelectionCharNr
v1.0.10
  • fixed: first lineNr was zero after initialization
  • fixed: bug in calculation of vertical scrollbar position
  • changed: flags in the TE_STRUCT are now a combination of "binary bit flags"
  • changed: renamed TE_CURSORSTATE\state to TE_CURSORSTATE\dragDropMode
  • added: PBEdit_SetFlag(ID, Flag, Value): set or clear the specified flag (eg. PBEdit_SetFlag(EditorID, #TE_EnableReadOnly, 1))
  • added: PBEdit_GetFlag(ID, Flag): get the specified flag
  • added: PBEdit_SetGadgetFont(ID, FontName$, FontHeight = 0, FontStyle = 0)
  • added: TE_STRUCT\foldChar (default: 1): a special character that indicates the foldstate of a newly inserted textline
  • added: horizontal autoscroll
v1.11
  • fixed: unintended scrolling after a textblock is folded/unfolded
  • fixed: folded textblock not unfolded, when text is edited
  • fixed: numpad return key not responding in linux
  • fixed: typo "laguage" renamed to "language"
  • fixed: autocomplete scrollbar not working
  • changed: the version number now has only two parts
  • changed: CanvasGadget with flag "#PB_Canvas_Container". The ScrollBars now are added to the views CanvasGadget
  • changed: added a ContainerGadget as parent for all views
  • changed: added Procedure PBEdit_Container(ID) to get the ID of the ContainerGadget
  • changed: removed x,y,width,height from TE_STRUCT since these values can be obtained from the ContainerGadget
  • changed: #TE_SyntaxCheck to #TE_SyntaxHighlight
  • changed: #TE_Flag_... to #TE_Syntax_... and #TE_Parser_...
  • changed: TE_COLORSCHEME/defaultTextColor to TE_COLORSCHEME/defaultText
  • changed: TE_COLORSCHEME/selectedTextColor to TE_COLORSCHEME/selectedText
  • changed: the blinking of the cursor is now controlled via thread (Draw_CursorThread) - enable "Create threadsafe executable" in the compiler options!
    if the value "cursorBlinkDelay" in the settings file is "0" the cursor is not blinking at all
  • changed: reduced unnecessary redrawing of unmodified textlines (less CPU usage when idle)
  • changed: renamed procedure Event_Resize to Editor_Resize
  • changed: improved speed of dictionary update
  • changed: improved syntax highlighting
  • added: PostEvent #TE_Event_Redraw with #TE_EventType_RedrawAll or #TE_EventType_RedrawChangedLines
  • added: Structure TE_REPEATEDSELECTION
  • added: TE_REPEATEDSELECTION\minCharacterCount: number of consecutive characters that have to be selected to highlight repeated selections
  • added: flag #TE_RepeatedSelection_WholeWord: highlight the whole word if Nr. of selected characters >= TE_REPEATEDSELECTION\minCharacterCount
  • added: flag #TE_EnableHorizontalFoldLines: if true, display a horizontal line over and under a foldable textblock
  • added: flag #TE_EnableSelection: enable/disable selecting of text
  • added: flag #TE_EnableAlwaysShowSelection: enable/disable display selection if not active gadget
  • added: flag #TE_EnableAutoClosingKeyword: enable/disable insertion of closing keyword after Tab-Key is pressed twice
v1.12
  • fixed: jump to bookmark (F2 key) didn't jump to the correct line
  • fixed: wrong indentation when the previous textline was a split line (has line continuation)
  • changed: renamed procedure Draw_CursorThread to Cursor_Thread
  • changed: the Cursor_Thread is posting the event #TE_Event_CursorBlink to the active editor
    the actual redrawing of the cursor takes place in the new Procedure "Event_Cursor".
    at the moment the blink delay is set to a fixed value (500 ms).
v1.13
  • fixed: mouse selection related issues
  • fixed: autocomplete scrollbar position
  • fixed: find/replace too slow due to permanent dictionary updates
  • fixed: typo #TE_Font_Undelined = #TE_Font_Underlined
  • fixed: case correction not undoable
  • fixed: ProcedureReturn before PopListPosition in Procedure Position_InsideComment
  • added: Ctrl+H - replace shortcut
  • added: flag #TE_EnableUndo: enable/disable undo
  • added: Procedure Textline_ChangeText: change text in place
  • added: flag #TE_Undo_ChangeText
  • changed: copy/paste with multicursor: each cursor now has it's own clipboard
  • changed: Procedure Event_Mouse now calling Event_Mouse_LeftButtonDown, Event_Mouse_LeftButtonUp and Event_Mouse_Move
  • changed: renamed TE_STRUCT\autoCompleteList to TE_STRUCT\dictionary
  • changed: optimization in Procedure Indentation_Range
  • changed: optimization in Procedure Folding_UnfoldTextline
v1.14
  • fixed: bug in Procedure Folding_Update when flag #TE_EnableFolding is false
  • fixed: typo #TE_Autocomplete_FindAtBegind
  • added flag #TE_EnableShowModifiedLines: when enabled, modified textlines are indicated by a orange line
  • added SplitterGadget to chage the size of splitted views
  • changed: replaced all occurances of .s with $ (just my personal taste)
  • changed: inside Structure TE_TEXTLINE: removed fields needRedraw.b, needStyling.b, marker.b, remark.b
    All these flags are now controlled by TE_TEXTLINE\flags and the values from the #TE_TextLine_... Enumeration
  • issues: strong flashing of the screen when resizing a splitted view with the splitterbar
    sometimes the "Unsplit View" function is not working correctly
    remark textlines' and 'word wrapping' is in an experimental stage and are not working correctly
https://github.com/MR-L-PB/PBEdit

Re: PBEdit - a Canvas-based Texteditor

Posted: Wed Sep 09, 2020 10:27 pm
by J. Baker
Very nice! It runs fine on OS X. I edited line 3438. The font size was small on my MacBook Air 11".

Code: Select all

*font\nr	= LoadFont(#PB_Any, fontName, (fontSize / DesktopResolutionY()) * 1.5, fontStyle)
At idle, it uses 12% CPU and 64 MB of memory. I have an Intel 1.4 Ghz dual core CPU. Not bad. ;)

Re: PBEdit - a Canvas-based Texteditor

Posted: Wed Sep 09, 2020 10:54 pm
by Andre
Well done, thanks for sharing! :D

Re: PBEdit - a Canvas-based Texteditor

Posted: Wed Sep 09, 2020 11:09 pm
by STARGĂ…TE
Wow, that's impressive.
I think this code is one of the first really working editors.

Many thanks for sharing.

How long did you worked on this version?

Re: PBEdit - a Canvas-based Texteditor

Posted: Wed Sep 09, 2020 11:16 pm
by Kiffi
Amazing! Image

Thanks for sharing ... Peter

Re: PBEdit - a Canvas-based Texteditor

Posted: Thu Sep 10, 2020 12:04 am
by oreopa
Very cool work. Multiple cursors mode seems to work great. Column selection mode like UltraEdit would be a nice addition.

Impressive and very useful. Thx.

Re: PBEdit - a Canvas-based Texteditor

Posted: Thu Sep 10, 2020 7:54 am
by dige
Wow, very impressive! Thx Mr. L!

Re: PBEdit - a Canvas-based Texteditor

Posted: Thu Sep 10, 2020 8:39 am
by Saki
An amazing work, really very beautiful !

Re: PBEdit - a Canvas-based Texteditor

Posted: Thu Sep 10, 2020 8:54 am
by Fred
Very nice

Re: PBEdit - a Canvas-based Texteditor

Posted: Thu Sep 10, 2020 9:09 am
by User_Russian
The editor only supports English characters and numbers.

Re: PBEdit - a Canvas-based Texteditor

Posted: Thu Sep 10, 2020 9:10 am
by infratec
Nice work.

I think horizontal and vertical split are swapped :wink:

Re: PBEdit - a Canvas-based Texteditor

Posted: Thu Sep 10, 2020 10:00 am
by Mesa
Very impressive.

With windows XP 32, there is something wrong with the pop-up menu.
I had to replace, line 874 and under:

Code: Select all

MenuItem(#TE_Menu_Cut, "Cut" + RSet("", 5, #TAB$) + "Ctrl+X")
by

Code: Select all

MenuItem(#TE_Menu_Cut, "Cut" + #TAB$ + RSet("", 5, " ") + "Ctrl+X")
etc.

Multi languages might be very useful :)


M.

Re: PBEdit - a Canvas-based Texteditor

Posted: Thu Sep 10, 2020 12:41 pm
by GoodNPlenty
Amazing, Thank You for sharing.

Re: PBEdit - a Canvas-based Texteditor

Posted: Thu Sep 10, 2020 4:06 pm
by useful
Thank you very much.
I'm trying to move to spiderbasic.

Re: PBEdit - a Canvas-based Texteditor

Posted: Thu Sep 10, 2020 4:51 pm
by skywalk
Great Job Mr.L :!:
The split view seems quirky, as infratec noted.