With SCI_STYLESETVISIBLE certain text segments can be made invisible. Editing a document with invisible text segments is rather confusing. The cursor can be left or right of an invisible segment. But the user sees the cursor in both cases at the same position while the editing possibilties are different (ie not being able to paste text).
In my application I use scintilla as an editor component and have implemented the command SCI_STYLESETINVISIBLEREP which sets an UTF8 string as a representation for invisible text segments. This UTF8 string, such as for example an 'operator bullet' indicates to the user the position of the invisible segement while the cursor can be placed at both ends of the representsation. Thus making an end to the confusion. The representation text has the same style as the hidden text segment.
If there is need for this feature I'm pleased to contribute it to this great community.
It is likely such a feature would be worthwhile so please publish the implementation.
I've not changed
Scintilla.ifaceAttached is the diff from the scintilla530.zip source
Do you use different representations for different styles? It seems to me that having a single representation for invisible text would be adequate
I've written a lexilla parser for XTG files. Different xtg commands get different lexilla styles. To represent an xtg paragraph or character style command I need another colour than for example the xtg optional hyphen command. The representation of the latter should also be as small as possible ('operator bullet'). The representation of the other lexilla styles can be bigger ('circle or 'bullet').
See the image attached. Below is the origional text, above some styles are made invisible. You image that editing the text in the above view is much easier than in the view below?
I suppose applying a small font size to
bulletdoesn't look as good?Stylegoes to a lot of effort to minimize memory by not storing a string for each font name and this change enlarges the size ofStyleby 25%. SeeViewStyle::fontNamesbut I'm not sure that is the best approach here. Another possibility is to reuse the character representation implementation which would also allow changing the colour or drawing the representation inside a blob.The representation layout code should be moved inside the parallelized
LayoutSegmentsfunction as execution has returned to a single thread at its current location. Its also not caching the resulting width which may be recalculated many times - see the way character representation widths can be retrieved from the cachepCache->MeasureWidths.To follow Scintilla conventions, 'representation' should be spelled out:
StyleSetInvisibleRepresentation, no underscores in variable names, and no tagging of UTF-8 strings like_utf8.SetAPIs should also have correspondingGetAPIs.I've changed the code like you asked. The size of
Stylenow has not grown at all! Only the first character of the UTF8 string will be stored in max 5 chars, which are on VS2022 already present as padding. Hope you like it.Last edit: Ferdinand Oeinck 2022-09-30
The test against
styleInvisibleRepresentationalways succeeds as its a pointer. You probably wantedstyleInvisibleRepresentation[0].Since the setter is calling
UTF8Classifyit should probably check the result for theUTF8MaskInvalidflag and do nothing when invalid.There should be a test case like this in the test directory just to check the APIs work:
There are some spare API numbers 2256 and 2257 near other style APIs. Changing Scintilla.iface is worthwhile as running
scripts/ScintillaAPIFacer.pyfixes everything up:styleInvisibleRepresentationis a member ofStyleso should be shortened toinvisibleRepresentationand can be fully initialized to all NULs with{}:There should be a short explanation of the APIs in
doc/ScintillaDoc.htmlmentioning that only a single character is supported.Attached are the latest changes.
Last edit: Ferdinand Oeinck 2022-10-02
The representation is displayed in the style of the invisible text but its measured in

StyleControlCharwhich results in wrong positions like this picture where strings are represented by●and overlap the,. Control characters are styled to be tiny to illustrate the issue withstyle.*.36=font:Verdana,size:1in SciTE.The comment for measuring was copied from the control character code so mentions
ts.representation->stringRepbut it should be mentioningtextorinvisibleRepresentation.In
Editor.cxxtheStyleGetChangeablecase was damaged by the patch.The documentation uses
invisibleRepresentationas the name of the parameter butScintilla.ifaceusesrepresentation. The parameter names should be consistent and this is checked byscripts/CheckMentioned.pyI changed all that and additionally removed the memcpy in Editor.cxx and guarded against an invalid UTF8 character. I also removed the
// focomments and the linercSegment.left += 0; // 2Last edit: Ferdinand Oeinck 2022-10-03
Committed with minor changes adding 'const' and formatting braces to follow conventions as [d72de4].
Also added
invisiblerepresentationstyle attribute to SciTE as [c4c724].Related
Commit: [c4c724]
Commit: [d72de4]
Committed with minor changes adding 'const' and formatting braces to follow conventions as [d72de4].
Also added
invisiblerepresentationstyle attribute to SciTE as [c4c724].Related
Commit: [c4c724]
Commit: [d72de4]