« il: 08 Novembre 2013, 15:28:19 »
Vi riporto questa discussione apparsa nella M.L. ufficiale:
"
want that my program, at a click of the button will do
some highlighting in the text in an editor (a component of
gambas that you can add to a form).
So, in the form_open() method, i set :programEdit.Styles[Highlight.Normal].Color = Color.Red
programEdit.Styles[Highlight.Keyword].Color = Color.DarkGreen
(my editor component is called programEdit)
then in the toolbutton1_click() method i set programEdit.Highlight = Highlight.Custom
(should this not call the programEdit_highlight() method?)
In the programEdit_highlight, I set:Dim z_c As Integer
Dim i As Integer
Dim z As String
Dim s As String
z = programEdit.Text '(this picks up the text in the editor)
z_c = String.Len(z)
For i = 1 To z_c
s = Mid(z, i, 1) 'pick up each character
If s = "s" Then 'i want the "s" -s to be dark green
'Message("resetting highlight")
Highlight.Add(Highlight.Keyword) 'according to the docs, this will set the highlight of a single character ..
Highlight.State = Highlight.Keyword 'i dont know if i needed this, but even dropping it has no effect
Else
Highlight.Add(Highlight.Normal)
Endif
Next
this should make the "s"- s dark green, and everything
else red, but i am seeing everything simply red. where did
i go wrong?
Sean[/i] "
"
The Editor control will highlight a line at a time. The current line will be
in Highlight.Text. If you always take the entire programEdit.Text, then you
will highlight the wrong things.
Regards,
Tobi "
"
Hi Tobi, thanks for the Answer.
Would it be too much if i request you do show me a Minimum
Working Example of the correct syntax?
The html-highlighter given in the Examples is too complex..
Sean "
"
I perfectly understand that. I once aimed at implementing a new interface
for Editor-like controls, similar to how one defines syntaxes for the vim
highlighting mechanism but with OOP. It will not make you write code but
just explain the syntax to the engine with objects. But this will happen
in the course of gb.ncurses and is not to happen soon.
Anyways, a minimal example is attached. (vedi allegato)
Regards,
Tobi "
Registrato
« Chiunque, non ricorrendo lo stato di necessità, nel proprio progetto Gambas fa uso delle istruzioni Shell o Exec, è punito con la sanzione pecuniaria da euro 20,00 a euro 60,00. »