PBEdit - a Canvas-based Texteditor

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
Mr.L
Enthusiast
Enthusiast
Posts: 104
Joined: Sun Oct 09, 2011 7:39 am

PBEdit - a Canvas-based Texteditor

Post 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
Last edited by Mr.L on Mon Jul 17, 2023 6:31 am, edited 26 times in total.
User avatar
J. Baker
Addict
Addict
Posts: 2178
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Re: PBEdit - a Canvas-based Texteditor

Post 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. ;)
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef

Mac: 10.13.6 / 1.4GHz Core 2 Duo / 2GB DDR3 / Nvidia 320M
PC: Win 7 / AMD 64 4000+ / 3GB DDR / Nvidia 720GT


Even the vine knows it surroundings but the man with eyes does not.
User avatar
Andre
PureBasic Team
PureBasic Team
Posts: 2056
Joined: Fri Apr 25, 2003 6:14 pm
Location: Germany (Saxony, Deutscheinsiedel)
Contact:

Re: PBEdit - a Canvas-based Texteditor

Post by Andre »

Well done, thanks for sharing! :D
Bye,
...André
(PureBasicTeam::Docs & Support - PureArea.net | Order:: PureBasic | PureVisionXP)
User avatar
STARGÅTE
Addict
Addict
Posts: 2067
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: PBEdit - a Canvas-based Texteditor

Post 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?
Last edited by STARGÅTE on Wed Sep 09, 2020 11:17 pm, edited 1 time in total.
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
User avatar
Kiffi
Addict
Addict
Posts: 1353
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: PBEdit - a Canvas-based Texteditor

Post by Kiffi »

Amazing! Image

Thanks for sharing ... Peter
Hygge
User avatar
oreopa
Enthusiast
Enthusiast
Posts: 281
Joined: Sat Jun 24, 2006 3:29 am
Location: Edinburgh, Scotland.

Re: PBEdit - a Canvas-based Texteditor

Post 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.
Proud supporter of PB! * Musician * C64/6502 Freak
dige
Addict
Addict
Posts: 1247
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Re: PBEdit - a Canvas-based Texteditor

Post by dige »

Wow, very impressive! Thx Mr. L!
"Daddy, I'll run faster, then it is not so far..."
User avatar
Saki
Addict
Addict
Posts: 830
Joined: Sun Apr 05, 2020 11:28 am
Location: Pandora

Re: PBEdit - a Canvas-based Texteditor

Post by Saki »

An amazing work, really very beautiful !
地球上の平和
Fred
Administrator
Administrator
Posts: 16619
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: PBEdit - a Canvas-based Texteditor

Post by Fred »

Very nice
User_Russian
Addict
Addict
Posts: 1443
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: PBEdit - a Canvas-based Texteditor

Post by User_Russian »

The editor only supports English characters and numbers.
infratec
Always Here
Always Here
Posts: 6817
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: PBEdit - a Canvas-based Texteditor

Post by infratec »

Nice work.

I think horizontal and vertical split are swapped :wink:
Mesa
Enthusiast
Enthusiast
Posts: 345
Joined: Fri Feb 24, 2012 10:19 am

Re: PBEdit - a Canvas-based Texteditor

Post 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.
GoodNPlenty
Enthusiast
Enthusiast
Posts: 107
Joined: Wed May 13, 2009 8:38 am
Location: Arizona, USA

Re: PBEdit - a Canvas-based Texteditor

Post by GoodNPlenty »

Amazing, Thank You for sharing.
User avatar
useful
Enthusiast
Enthusiast
Posts: 367
Joined: Fri Jul 19, 2013 7:36 am

Re: PBEdit - a Canvas-based Texteditor

Post by useful »

Thank you very much.
I'm trying to move to spiderbasic.
Dawn will come inevitably.
User avatar
skywalk
Addict
Addict
Posts: 3972
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: PBEdit - a Canvas-based Texteditor

Post by skywalk »

Great Job Mr.L :!:
The split view seems quirky, as infratec noted.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Post Reply