Forum > SynEdit

A few questions about SynEdit.

<< < (2/2)

rvk:

--- Quote from: CM630 on February 21, 2024, 08:57:47 am ---So far 3 problems occurred:
1. MyMarkup.SearchOptions := [ssoWholeWord]; does not work for me (see the screenshot attached).
2. I do not know how to change the colour of the underline.
3. I do not know how to make the underline curly.

--- End quote ---
With 2 and 3, weren't you already on your way with that FrameColor ?????


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---    // myMarkup.MarkupInfo.FrameColor := clBlue;    // myMarkup[i].MarkupInfo.Style :=  [TFontStyle.fsUnderline];    myMarkup[i].MarkupInfo.FrameColor := clRed;    myMarkup[i].MarkupInfo.FrameEdges := sfeBottom;    myMarkup[i].MarkupInfo.FrameStyle := slsWaved;
If you want other styles you probably need to rewrite a (highlighting) component part.

The problem if number 1 is that TSynEditMarkupHighlightAll probably doesn't support UTF-8 completely.
The extended characters beyond 128 will be seen as word boundary.

I checked this by testing some text and using "us" as text.
See image. You see "using" isn't detected but the us in "uséing" is.
(and all those characters in your language are probably extended characters and not standard ascii.)

Martin_fr:
First of all, to clarify my previous answer.

It is technically possible to do the wrong word underlining using a highlighter. It is just not the way it was designed. And, you can only use ONE highlighter, so if you use it for this, then you can't use it for anything else.

There is a wiki on markup https://wiki.freepascal.org/SynEdit_Markup but yes no examples.

Yes, SyneditBase must always be a full SynEdit => It is only there to avoid circular unit uses.

Why do you remove one of the existing Markups?
You can add yours, without removing one.
Some of the existing Markup are essential (like showing the current selected text is a markup - I don't think you want to remove that?)


Red curly underline ("m" is the markup)

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---uses SynEditTypes;...  m.MarkupInfo.FrameEdges := sfeBottom;  m.MarkupInfo.FrameStyle := slsWaved;  m.MarkupInfo.FrameColor:= clRed; 

--- Quote ---MyMarkup.SearchOptions := [ssoWholeWord]; does not work for me (see the screenshot attached).
--- End quote ---
The screenshot seems missing?
But anyway, you are right => that only works for Latin at the moment. The internally used "FSearch: TSynEditSearch" has "property IdentChars: TSynIdentChars" which is a "set of char" and therefore only support Latin.

But the idea was that you would subclass the markup, with your own code.
Having more than one markup ("myMarkup: array of TSynEditMarkupHighlightAll;") is not the way to go.

You should override

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function TSynEditMarkupHighlightAll.FindMatches
Look at the original code.

You would not use "fSearch.FindNextOne", but you would go through the text yourself.

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---for i := AStartPoint.y - 1 to AEndPoint.y-1 do begin // those are 1-based // lines is 0-based  linetext := lines[i];  // check  for misspelled words  LStart := 1;  LEnd := length(linetext):  for xpos := LStart to LEnd do begin  end ;  // e.g. find next word start, find the end, take the word and spellcheck it .......   if ... then     FMatches.Insert(...)end;
And then any words found are added: "FMatches.Insert(...)" // FMatches are NOT allowed to be multi-line.

On the first and last line you should also check the X pos. Any word found must be at least partially inside the line-part given by X.
If AStartPoint.x is in the middle of a word  AStartPoint.x = 7  and linetext ="ab verylongword" then IIRC you should find verylongword too.


If ABackward is set, then you must find ONLY ONE word (or NONE) which is the first that you find going backwards from end-pos.

Result is the start of the last (or for ABackward the only) found word.

Martin_fr:
Mind, in case you want to optimize.

If you change text in SynEdit, the matches for the changed line(s) will be removed, and FindMatches will be called again on that line(s). If your dictionary is not that fast, then you could for the line with the caret, cache known good words. (the line with the caret is the one that gets most of the searches).

CM630:


--- Quote from: rvk on February 21, 2024, 10:00:19 am ---
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---    myMarkup[i].MarkupInfo.FrameColor := clRed;    myMarkup[i].MarkupInfo.FrameEdges := sfeBottom;    myMarkup[i].MarkupInfo.FrameStyle := slsWaved;
--- End quote ---
Thanks, that works just perfect!



--- Quote from: rvk on February 21, 2024, 10:00:19 am ---The problem if number 1 is that TSynEditMarkupHighlightAll probably doesn't support UTF-8 completely.
The extended characters beyond 128 will be seen as word boundary.

--- End quote ---
Indeed, @Martin_fr confirmed it below.



--- Quote from: Martin_fr on February 21, 2024, 10:29:27 am ---Why do you remove one of the existing Markups?

--- End quote ---
I have no idea what their purpose is, I decided it is safer this way.
But I wll try without removing them.



--- Quote from: Martin_fr on February 21, 2024, 10:29:27 am ---The screenshot seems missing?

--- End quote ---
Indeed, I have added it now.



--- Quote from: Martin_fr on February 21, 2024, 10:29:27 am ---But the idea was that you would subclass the markup, with your own code.

--- End quote ---
If it worked the current way, it would be okay for me. It is for an application which will rarely have more than 3 lines per text at the same time.


I need time and efforts to comprehend everything else...

Navigation

[0] Message Index

[*] Previous page

Go to full version