|
Post by rogercabo on Feb 16, 2023 23:15:12 GMT 1
Hi everyone, because I have troubles with the rtf textbox and selecting words fast, Does anyone wrote a simple text editor that use graphic outputs with Text , , $ ?
Otherwise I must write one, but the ugly thing is text selection copy and past over several lines and a simple undo. But writing a text editor with automatic line wrapping is a nightmare containing selection copy and paste... or?
|
|
|
Post by rogercabo on Feb 17, 2023 1:24:33 GMT 1
And a proportional font is also another nightmare containing selection copy and paste and displaying the word with a red underline. Holy Molly!
|
|
|
Post by (X) on Feb 17, 2023 2:43:08 GMT 1
|
|
webu
Full Member
 
Posts: 101
|
Post by webu on Feb 17, 2023 10:41:11 GMT 1
I had written a very simple editor for my CAD program 30 years ago and it could do continuous text (for non-prop Atari fonts). If I needed more functions, I quickly passed the text over a shortcut to a real, external editor. When I finished this editor, I read the text back into my editor.
This was a very quick workaround, but I kept it until today.
|
|
|
Post by dragonjim on Feb 17, 2023 13:56:57 GMT 1
I have started writing many, finished only one (very basic) and abandoned the rest due to the complexity involved and lack of time.
Most of mine were based on HTML coding to make them more compatible with import and export; however, if you are only after a simple text editor, I would advise using only simple HTML tags and ignore the rest - and use an Ocx Form as your base...
Oh yes, and sort out the text rendering before you try and tackle the editing...
|
|
|
Post by rogercabo on Feb 17, 2023 14:07:13 GMT 1
Unfortunately the behavior is the same in VB6. And I have no idea to use the RTBCompose and it seems a complete different system control based on .Net like gfabasic32 use.
|
|
|
Post by rogercabo on Feb 17, 2023 14:11:50 GMT 1
I had written a very simple editor for my CAD program 30 years ago and it could do continuous text (for non-prop Atari fonts). If I needed more functions, I quickly passed the text over a shortcut to a real, external editor. When I finished this editor, I read the text back into my editor. This was a very quick workaround, but I kept it until today. Yes that seems to be a good start.. Perhaps I can add a proper line break in and use proportional fonts.
|
|
|
Post by rogercabo on Feb 17, 2023 14:16:01 GMT 1
I have started writing many, finished only one (very basic) and abandoned the rest due to the complexity involved and lack of time. Most of mine were based on HTML coding to make them more compatible with import and export; however, if you are only after a simple text editor, I would advise using only simple HTML tags and ignore the rest - and use an Ocx Form as your base... Oh yes, and sort out the text rendering before you try and tackle the editing... Do you know what text output command gfabasic use?
|
|
|
Post by (X) on Feb 17, 2023 14:22:33 GMT 1
Silly question... Did you check this demo included as a GFA-BASIC 32 sample: "LoadRichEdit50W.G32"? $Library "gfawinx"
If !LoadRichEdit50W() ' should not happen MsgBox0 "Failed to load msftedit.dll. Falling back to RichEdit version 3.0 (RichEd20.dll)" EndIf
OpenW 1, 0, 0 Me.Sizeable = 0 Ocx Timer tmr : .Interval = 500 : .Enabled = 1 Ocx RichEdit rtf = , 0, _Y / 2, _X, _Y / 2 rtf.HideSelection = 0 rtf.SelText = String( 5, "GFA-BASIC 32 ") rtf.SelItalic = 1 rtf.SelText = String( 5, "GFA-BASIC 32 ") rtf.SelBold = 1 rtf.SelText = String( 5, "GFA-BASIC 32 ") rtf.SelItalic = 1 rtf.SelText = String( 5, "GFA-BASIC 32 ") rtf.SelStart = 1 : rtf.SelLength = 0 Do Sleep Loop Until Me Is Nothing LoadRichEdit50W '(False)
Sub tmr_Timer Local Int l Static Int direction = 0 l = rtf.Find("BASIC", rtf.SelStart + 1, -1, direction) If l < 0 Then direction = (direction == 0 ? 1 : 0) ' tmr.Enabled = False End Sub
RTF-Control.g32 (4.25 KB)
|
|
|
Post by rogercabo on Feb 17, 2023 15:21:47 GMT 1
Yes :-) None of these example work in any way while typing into and the code is selecting any text by .SelXXX. So generally you can say, FRT have not the capabilities to write a text and spell check in real time..
Unfortunately..
The only way is to write a text editor by you self. where you can control the complete behavior while writing in check in real time. I spend so many time into rtf stuff, for real I had used the time to write my own simpler one.
|
|
|
Post by dragonjim on Feb 17, 2023 15:48:21 GMT 1
I have started writing many, finished only one (very basic) and abandoned the rest due to the complexity involved and lack of time. Most of mine were based on HTML coding to make them more compatible with import and export; however, if you are only after a simple text editor, I would advise using only simple HTML tags and ignore the rest - and use an Ocx Form as your base... Oh yes, and sort out the text rendering before you try and tackle the editing... Do you know what text output command gfabasic use? Use the basic Text command if you are using an Ocx Form... ..but if you want to print Unicode characters, you will need a customised TextW routine like: Procedure TextW(x!, y!, wstr As String, Optional a As Variant) // Acknowledgements in part to Sjouke Hamstra // wstr is formatted as a 16-bit BSTR string // a gives the option to draw angled text Local Int32 esc, ori : Local fnt As Handle = Me.Font._hFont : Local dummy$ // Adjust for scaling x! = ScaleX(x! - ScaleLeft, ScaleMode, basPixels) y! = ScaleY(y! - ScaleTop, ScaleMode, basPixels) x! = (x! * ScaleMX) - ScaleX(Int(ScaleLeft * ScaleMX), ScaleMode, basPixels) - ScaleMX y! = (y! * ScaleMY) - ScaleY(Int(ScaleTop * ScaleMY), ScaleMode, basPixels) - ScaleMY // Set angle if required If Not IsMissing(a) : RFont Escapement esc : RFont Orientation ori Font Escapement a, Orientation a : Font To fnt : SetFont fnt EndIf // Don't care about 2 terminating 0-bytes, because we pass Len/2. TextOutW(Me.hDC, x!, y!, V:wstr, Len(wstr) / 2) // If AutoRedraw = True draw on bitmap. If Me.hDC2 Then TextOutW(Me.hDC2, x!, y!, V:wstr, Int(Len(wstr) / 2)) // Reset angle if required If Not IsMissing(a) Then Font Escapement esc, Orientation ori : Font To fnt : SetFont fnt EndProcedure
|
|
|
Post by (X) on Feb 18, 2023 0:31:39 GMT 1
I am experimenting...
So far, I can parse the text in the RTF and maintain a list of unique words. Next, will be to highlite the new words (not found in the dictionary) for manual inclusion.
Attachments:Demo Spell Checker.g32 (6.95 KB)
|
|
|
Post by rogercabo on Feb 18, 2023 23:23:15 GMT 1
I am experimenting...
So far, I can parse the text in the RTF and maintain a list of unique words. Next, will be to highlite the new words (not found in the dictionary) for manual inclusion.
Tested it... good solutions for adding a new dic and searching through the text is also a nice and easy solution!
|
|
|
Post by (X) on Feb 18, 2023 23:43:44 GMT 1
I am working out speed optimizations...
|
|
|
Post by rogercabo on Feb 20, 2023 20:27:25 GMT 1
If your able to write into the rtf1 text box without a glitch, or losing scroll position, or losing the cursor position, and recoloring at the same time, you're my hero :-)
|
|
|
Post by (X) on Feb 21, 2023 0:46:07 GMT 1
If your able to write into the rtf1 text box without a glitch, or losing scroll position, or losing the cursor position, and recoloring at the same time, you're my hero :-)
I'm getting pretty close to that...
A selection of a new word hilites it in the text.
A right click on a selected new word puts it into the dictionary. Some toolbar buttons are functional.
Attachments:Demo Spell Checker.g32 (56.17 KB)
|
|
|
Post by (X) on Feb 23, 2023 5:02:03 GMT 1
Here is the latest version...
A noticeable improvement is the restoration of the original selection when coming back to the RichEdit control.
N.B.: 1) Some toolbar buttons have still not been activated. 2) There are at least 2 versions of the RichEdit DLL that can be implemented. I am thinking the latest version may use Wide or Unicode characters therefore I have not used it in favour of the older version that I think uses single Byte characters. I have to try out a few tests to find out what's what. Evidently, if one chooses one version or the other, one may have to start converting ANSI to WIDE strings or vis-versa. It is probably preferable to get the Unicode version to work to take advantage of the wider range of symbols.
|
|
|
Post by (X) on Feb 23, 2023 5:11:17 GMT 1
Here are the Dictionary Hash file and the RichEdit text file that I am using...
|
|
|
Post by scalion on Mar 3, 2023 22:31:18 GMT 1
J'ai écrit un tas d'éditeur de texte en tout genre.
|
|
|
Post by rogercabo on Mar 13, 2023 22:40:33 GMT 1
J'ai écrit un tas d'éditeur de texte en tout genre.
WOW..
Did you have the file for $Library "c:\nicolas\g32\MyFunctions" ? The Basic 9 seems to be interesting..  Je veux créer un éditeur de texte avec une police proportionnelle et une fonction de saut de ligne, et pendant que vous tapez, une fonction de dictionnaire recolorera les mots s'ils sont mal orthographiés. Le truc du dictionnaire fonctionne parfaitement.. Seulement le champ de texte richedit ne veut pas. Le plus gros problème est de sélectionner et de recolorer n'importe quel mot pendant l'écriture et la sélection. Cela provoque un saut et une reposition du curseur et il est impossible d'écrire.
Actuellement, je suis en train de développer un éditeur de texte. Je pense qu'il doit insérer des caractères de contrôle devant les mots mal orthographiés et les afficher dans une couleur différente lors de l'affichage. Une fonctionnalité pour le saut de ligne automatique et la position correcte du curseur pendant la saisie sont également des défis à relever !
|
|
|
Post by scalion on Mar 15, 2023 15:10:23 GMT 1
Ma librairie MyFunctions, mais elle un peu obsolète... j'avais complètement oublié son existence. Si ca peut te servir 
Si tu veux vraiment créer un bon editeur de texte je te conseilles d'utiliser DIRECT2D Avec cette librairie tout est prévu pour cela, jette un oeil sur cette fonction en particulier : D2TL_HitTestTextPos
De plus tu pourras facilement colorer le texte etc... de manière purement graphique (sans passer par la contrainte d'un controle externe mais avec la difficulté toute relative d'avoir tout à faire).
Il va falloir prioritairement implémenter méthodiquement les fonctions
- BackSpace
- Delete - Tabulation - Left/Right/Up/Down
- PageUp - PageDown
Et penser surtout à comment tu mémorise le texte (tableau de chaines ou malloc() avec tableau d'index, ou les 2).
Bon courage et si tu as une question ou besoin d'un coup de main je suis là !!!
|
|