Page 1 of 4

TextEdit Gadget

Posted: Fri Sep 16, 2011 11:20 am
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

Re: TextEdit Gadget

Posted: Fri Sep 16, 2011 12:56 pm
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 ?

Re: TextEdit Gadget

Posted: Fri Sep 16, 2011 2:41 pm
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!

Re: TextEdit Gadget

Posted: Sat Sep 17, 2011 9:28 am
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

Re: TextEdit Gadget

Posted: Sat Sep 17, 2011 11:10 am
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 :)

Re: TextEdit Gadget

Posted: Sat Sep 17, 2011 6:53 pm
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: )

Re: TextEdit Gadget

Posted: Sat Sep 17, 2011 8:04 pm
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?

Re: TextEdit Gadget

Posted: Sat Sep 17, 2011 8:13 pm
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 :)

Re: TextEdit Gadget

Posted: Sat Sep 17, 2011 8:17 pm
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 :)

Re: TextEdit Gadget

Posted: Sun Sep 18, 2011 2:30 pm
by Polo
Image

Text formatting is finished :)
Gonna look into the line wrapping now, the hardest part!

Re: TextEdit Gadget

Posted: Sun Sep 18, 2011 9:05 pm
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... ?

Re: TextEdit Gadget

Posted: Sun Sep 18, 2011 9:55 pm
by Polo
Didn't really look into that, but if you find a good file format definition it shouldn't be hard :)

Re: TextEdit Gadget

Posted: Mon Sep 19, 2011 9:49 am
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!. ;)

Re: TextEdit Gadget

Posted: Mon Sep 19, 2011 10:47 am
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:

Re: TextEdit Gadget

Posted: Mon Sep 19, 2011 12:03 pm
by flaith
Thanks a lot Polo, definitely this canvas gadget open the way of making a lot of great things :D