[Solved for now] Getting the exact amount of text shown in a richtext editor
Posted
#1
(In Topic #871)
Regular

I have previously posted about colors and backgrounds of richtext editor content. My goal is to create an IDE for a language I am working on. The IDE will have syntax highlighting in the text edit in the left hand pane, and a autogenerated program flowchart in the right hand side.
Now, I was lookign for efficient syntax highlight algorithms. I found this and this.
I would like to apply syntax highlighting only on the visible part of the text tho. I would like to find out if i can find out the exact amount of the text displayed in a richtextedit. See Image
<IMG src="https://i.imgur.com/91BxogK.png">
</IMG>.I only want to extract the text that starts at eirmod at the beginning of the visible text block, and ends at Lorem at the end (depending on the scroll bar position). Please note, that there are strokes of a p and a g of the previous line only barely visible at the very top, but I dont want the text of that line.
How can I extract only the visible text block? Thank you.
Posted
Guru

If you are looking for an IDE editor, why not use the same one that Gambas uses: -
<IMG src="https://www.cogier.com/gambas/TextEditor.png">
</IMG>
Posted
Regular

I could not find out how to do all that in the textEdit. So i am going with richtextedit.
Posted
Guru

You will need the ScrollY position, you will have to calculate from Font.Height, ScrollY position and TextEdit.Height
You will also need to deal with the text wrapping.
You may find it easier to use gb.form.editor
Check out this application…
Files · old-gambas · Bruce Steers / scripted · GitLab
That is an editor i made for making bash/gambas scripts using the gambas editor.
At the time I made it gambas did not support sh highlighting.
So I imported the gambas gb.form.editor and gb.eval.highlight components into the program. I then made a copy of the c++ highlighter and called it sh and edited it to work on sh files.
In the .src folder are 2 folders gb.form.editor and gb.eval.highlight. These are the imported/edited files with the TextHighlighter_Sh.class.
The work I did there was good enough to get included with gambas and sh highlighting is now available to all.
If you can see what the file .src/gb.eval.highlight/TextHighlighter_Sh.class · old-gambas · Bruce Steers / scripted · GitLab is doing then you may be able to copy it as i did and modify to your needs.
BruceS
Posted
Regular

I am trying to figure out how the actual highlighting is working in the control, that is whether it is a greedy algorithm.
1 guest and 0 members have just viewed this.


