TextEdit Gadget

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

TextEdit Gadget

Post by Polo »

My latest experiments with the canvas gadget :)

Image

This is the equivalent of an Editor Gadget, although this is a canvas. At the moment it provides nothing more than the Editor Gadget, and nothing less I hope (except line wrap maybe, not even sure this is natively supported). Everything is drawn and controlled through PB command set :)

My plans are to add optional line wrap, then text formatting, then other features (live scrollbars, inline pictures etc?)
As this is a canvas, everything is crossplaform!

Give it a try! In the file you'll find the MacOSX and Windows executables. I must say I developped this on the Mac, didn't really test the Windows version though it seems to work fine.
Try as well the keyboard shortcuts like alt+right and so on to see if i haven't forgotten any :)

http://www.megaupload.com/?d=XQ5NQI3A
Last edited by Polo on Thu Oct 20, 2011 12:13 am, edited 1 time in total.
User avatar
STARGÅTE
Addict
Addict
Posts: 2067
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: TextEdit Gadget

Post by STARGÅTE »

good work!

I love the canvas gadget. After #PB_Canvas_Input was added, I also wrote my own text editor.

In my editor, I can already use styles.
Here I use a kind of RTF format that is read at run time, how will you incorporate styles?

will be able to integrate into your editor mathematical formulas, like this older example from me: http://www.purebasic.fr/german/viewtopi ... 53#p269553 ?
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
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Re: TextEdit Gadget

Post by Polo »

Nice one too!
I'll add text formatting the same way I did with my GridGadget, should be too hard thus (not RTF at all though, I did it the way I though was the easiest) :)

Good idea with the maths editor, maybe I'll look into that too!
jesperbrannmark
Enthusiast
Enthusiast
Posts: 536
Joined: Mon Feb 16, 2009 10:42 am
Location: sweden
Contact:

Re: TextEdit Gadget

Post by jesperbrannmark »

I really think you and I have some kind of subconscious connection. I wrote a post about the listicongadget being outdated and maybe the canvasgadget could be the solution.. Next day you posted the gridgadget.... Last night I thought I need to write this to be able to do textedit (with some simple bold, italics, etc etc) on multiplatform. Woke up (my birthday by the way) and here it is.

Would be nice if you would decide to share the code :wink:
Anyhow, thats all up to you but thanks for the good stuff. I am impressed..

J
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Re: TextEdit Gadget

Post by Polo »

:mrgreen:
Happy birthday :)

Well I think those kind of gadgets are essential, and the two main OS should be supported :)
I'm working on the text formatting right now, more or less working, encountered the PB text drawing bug when using very large font (on MacOSX the bottom of the text is cut if the font is large), hope it'll get fixed :)

If I'm satisfied with it I'll release it, one way or another!
I really like the math equation idea Stargate showed, as I'm not satisfied with the MS Word one (if you write a fraction it's way too small), I'll try to add something like this too :)
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Re: TextEdit Gadget

Post by Polo »

With text formatting:

http://www.megaupload.com/?d=TINQVLW4

On both platform I shouldn't use the built in underline, as if you have two font sizes used on the same line and both underlined, it won't make a straight underline...
On MacOSX, PB returns incorrect TextWidth and TextHeight, thus my calculation to vertically align the text on a same line is a bit incorrect when there is a big difference in font size.

Other than that, it seems to work fine.
You can try and change the different options :)

Next steps is to correct the underline, implement color formatting, strike through formatting, and then line wrap.

(can't believe how much work it is :mrgreen: )
User avatar
STARGÅTE
Addict
Addict
Posts: 2067
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: TextEdit Gadget

Post by STARGÅTE »

good work.

but one bug here:
situation:
Image
and after i press two times DEL-key:
Image

the "w" is bold, but why?
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
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Re: TextEdit Gadget

Post by Polo »

Thanks for the report! I wrote everything on the Mac, which has no Del key, and didn't test at all on Windows :mrgreen:

I'll look into it, mustn't be a big deal :)
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Re: TextEdit Gadget

Post by Polo »

Fixed, wasn't a big deal indeed :wink:
I'll post an update soon when I have some more features, already added a new underline formatting, as well as strikethrough and color :)
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Re: TextEdit Gadget

Post by Polo »

Image

Text formatting is finished :)
Gonna look into the line wrapping now, the hardest part!
jesperbrannmark
Enthusiast
Enthusiast
Posts: 536
Joined: Mon Feb 16, 2009 10:42 am
Location: sweden
Contact:

Re: TextEdit Gadget

Post by jesperbrannmark »

It reminds me a lot of the richtext control from VB (or gfabasic in my case), a part i really been missing in PB (especially for mac). A question that is a bit more tricky is how to save and load documents... ?
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Re: TextEdit Gadget

Post by Polo »

Didn't really look into that, but if you find a good file format definition it shouldn't be hard :)
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: TextEdit Gadget

Post by c4s »

Polo wrote:Gonna look into the line wrapping now, the hardest part!
I made some really simple (not optimized) code for this, here (take a look on the third example):
http://www.purebasic.fr/english/viewtop ... 12&t=45192

And here is a rather complex code from idle for his TextEditGadget (also using Canvas, don't stop coding yours though!) :
http://www.purebasic.fr/english/viewtop ... 12&t=45669


Btw, do you plan to release your source code? Would be great!. ;)
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Re: TextEdit Gadget

Post by Polo »

Thanks c4s, it's quite hard to implement in my gadget as it needs to take into account all formatting etc ;)
Already 3,000 lines of code :oops:
User avatar
flaith
Enthusiast
Enthusiast
Posts: 704
Joined: Mon Apr 25, 2005 9:28 pm
Location: $300:20 58 FC 60 - Rennes
Contact:

Re: TextEdit Gadget

Post by flaith »

Thanks a lot Polo, definitely this canvas gadget open the way of making a lot of great things :D
“Fear is a reaction. Courage is a decision.” - WC
Post Reply