Page 2 of 3
Re: Build a text editor
Posted: Mon Jul 14, 2025 3:59 pm
by miso
I find this project interesting, I'm following your posts.
Re: Build a text editor
Posted: Sat Jul 19, 2025 12:22 am
by Olli
Thank you miso ! I think I will find a little bit of time tomorrow to add the third simulation.
Re: Build a text editor
Posted: Sun Jul 27, 2025 7:08 pm
by Nituvious
This is so much fun. I did the same thing a several years ago that I use as my primary editor for c/javascript(weird combo I know).
One thing to look into is the Language Server Protocol. It will help you index source code and provide you with autocomplete and many more tools that make today's editors do their fancy things! Also, once you create a client it's pretty simple to add support for several languages EXCEPT TernJS which is really nice but does whatever the hell it wants and don't not even follow any no language server protocols.
Re: Build a text editor
Posted: Tue Jul 29, 2025 10:11 pm
by Olli
@nituvious
I wasn't aware such a system existed. However, I don't think I'll ever create a server adapted for this, not entirely, anyway. The fit I see is between a server and the "Undo/Redo" function.
Also, I once made a word processor for a 16-bit ASM compiler (which I also designed), with the "undo/redo" function. The ASCII code of the keyboard keys was sufficient to generate a bytecode.
I also made a chess game 30 years ago; another bytecode, obviously, and a tree was required.
So it's likely that a blend of these two concepts would do the trick.
If you can think of any mistakes to avoid so as not to have to recode everything if this server concept becomes necessary, I'm interested.
Thank you for this tip, and I admit to be late (I am often tired by the work). Note that the next simulation will be more basic than a a system with integrated server.
The next step will have two views : the main one, and the general one. A tip I imagine day after day without computer to find easily a place in the text. It is really a thing I do not see everywhere, And there is an ergonomic risk : the general view should not take lots of space. But it should be easily visible even...
Re: Build a text editor
Posted: Tue Jul 29, 2025 11:46 pm
by acreis
I worked a lot in a text editor, my greatest struggle was with undo.
But the need of speed killed my project. I give up when I changed my display to 4k.
In 4k my drawing routines are noticeable slower than native windows control richedit. Even in a good gamer laptop.
I needed something better - for instance, smallcaps, justified paragraph alignment - and now richedit has it.
So I'll stick to richedit.
Re: Build a text editor
Posted: Wed Jul 30, 2025 9:50 pm
by Olli
However, pureBasic has natively the power to display and scroll such a text.
"4K" : what is it ?
Re: Build a text editor
Posted: Thu Jul 31, 2025 6:00 am
by miso
"4k"
Desktop resolution like 3840 x 2160 pixels. 2D Draw commands becomes slower with the higher resolution.
Re: Build a text editor
Posted: Thu Jul 31, 2025 6:08 pm
by Olli
Thank you miso for this info.
So, even if the flow is completely different between the two following devices, a printer device has a resolution similar (or above) to the 4K device.
Draw won't be used every screen frame.
OS GUI : images (plus a 1-dot canvas for input devices)
Full screen : sprites
Re: Build a text editor
Posted: Thu Jul 31, 2025 8:14 pm
by miso
True. As you said, there are methods to make this faster.
Re: Build a text editor
Posted: Sun Aug 10, 2025 7:34 am
by Nituvious
acreis wrote: Tue Jul 29, 2025 11:46 pm
I worked a lot in a text editor, my greatest struggle was with undo.
But the need of speed killed my project. I give up when I changed my display to 4k.
In 4k my drawing routines are noticeable slower than native windows control richedit. Even in a good gamer laptop.
I needed something better - for instance, smallcaps, justified paragraph alignment - and now richedit has it.
So I'll stick to richedit.
It sounds like you are generating sprites/textures every frame. You only need to do this when a change has happened. Should speed everything up!
Another annoying issue is large text files. I used streams to read content of a file as I scrolled, this helped a lot.
Re: Build a text editor
Posted: Mon Aug 18, 2025 12:24 am
by Olli
Owoowush ! I am alive ! (and tired lil bit...). What about a small concrete scrolling on the (burp...) "Window GUI" ?
3rd simulation, just to see, no problem of speed, except if you see anything boring !
Artefacts ? Freeze ? Anything boring ?
-> Write your misery, I ll try to clear !
Code: Select all
win = OpenWindow(#PB_Any, 0, 0, 1, 1, "", #PB_Window_ScreenCentered | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget | #PB_Window_Maximize | #PB_Window_SystemMenu | #PB_Window_SizeGadget)
w = WindowWidth(win)
h = WindowHeight(win)
max = 255
Global Dim img(max)
Global Dim ig(max)
con = ContainerGadget(#PB_Any, 0, 0, w, h)
visibleRowQty = h / 16
font0 = LoadFont(#PB_Any, "courier new", 12)
font1 = LoadFont(#PB_Any, "courier new", 12, #PB_Font_Bold | #PB_Font_Italic)
For i = 0 To max
img(i) = CreateImage(#PB_Any, w, 16)
StartDrawing(ImageOutput(img(i) ) )
Box(0, 0, w, h, RGB(255 - Random(31), 255 - Random(31), 255 - Random(31) ) )
DrawText(0, 0, Str(i) + " line #" + Str(i + 1), RGB(0, 0, 0), RGB(255, 255, 255) )
If Random(1)
DrawingFont(FontID(font0) )
Else
DrawingFont(FontID(font1) )
EndIf
DrawingMode(#PB_2DDrawing_Transparent)
DrawText(100 + Random(w - 200), 0, Str(i) + " line #" + Str(i + 1), RGB(Random(85), Random(85), Random(85) ), RGB(255, 255, 255) )
StopDrawing()
ig(i) = ImageGadget(#PB_Any, 0, 16 * i, 1, 1, ImageID(img(i) ) )
Next
CloseGadgetList()
winC = OpenWindow(#PB_Any, 0, 0, 1, 1, "", #PB_Window_BorderLess)
gadC = CanvasGadget(#PB_Any, 0, 0, 1, 1, #PB_Canvas_Keyboard)
SetActiveGadget(gadC)
Repeat
SetWindowTitle(win, "Wheel the mouse " + Str(WindowMouseX(win) ) + " * " + Str(WindowMouseY(win) ) )
ev = WaitWindowEvent()
SetActiveGadget(gadC)
If WindowMouseX(win) <> -1 And WindowMouseY(win) <> -1
dmx = DesktopMouseX()
dmy = DesktopMouseY()
ResizeWindow(winC, dmx, dmy, 1, 1)
wd = GetGadgetAttribute(gadC, #PB_Canvas_WheelDelta) * 3
While wd
oldOffset = offset
If wd < 0
offset + 1
wd + 1
If offset + visibleRowQty > max
offset = max - visibleRowQty
EndIf
Else
offset - 1
wd - 1
If offset < 0
offset = 0
EndIf
EndIf
If offset <> oldOffset
For i = 0 To visibleRowQty
SetGadgetState(ig(i), ImageID(img(i + offset) ) )
Next
EndIf
Wend
EndIf
Until ev = #PB_Event_CloseWindow
Re: Build a text editor
Posted: Mon Aug 18, 2025 12:27 am
by miso
Fancy, I like it!
Re: Build a text editor
Posted: Mon Aug 18, 2025 12:38 am
by Olli
Thank you miso !
I have more problem to fix this GUI which has not changed since Windows 3 than already know how to do the final !!!
All is embedded in the container named con. But two hours wasted to observe no click can be detected in this gadget... Anyway....
Re: Build a text editor
Posted: Mon Aug 18, 2025 12:54 am
by Olli
I can see 44 lines (whom the height is 16 pixels) on one screen. Who has more ?
What are your maximum ? (y resolution)
Re: Build a text editor
Posted: Mon Aug 18, 2025 1:08 am
by miso
44 Here, 64 on my other (1080 pix Height)