Discussion:
caret width in Overstrike on gtk is half the width on win32.
(too old to reply)
johnsonj
2014-07-05 08:21:21 UTC
Permalink
a patch attached.
I don't why exactly but it works.
please have a look.
thanks
-------------------------------------------------------------------------------------------------------
--- ../scintilla/src/Editor.cxx 2014-06-16 10:39:28.000000000 +0900
+++ Editor.cxx 2014-07-05 16:04:39.128083892 +0900
@@ -3432,9 +3432,20 @@
rcCaret.right = rcCaret.left + vsDraw.caretWidth;
} else if (inOverstrike && drawOverstrikeCaret) {
/* Overstrike (insert mode), use a modified bar caret
*/
+ #ifdef _WIN32 //by johnsonj
+ int numCharsToDraw = 1;
+ #else
+ int posBefore =posCaret.Position();
+ int posAfter = MovePositionOutsideChar(posBefore + 1,
1);
+ int numCharsToDraw = 1;
+ numCharsToDraw = posAfter - posBefore;
+ if (numCharsToDraw == 0) {
+ numCharsToDraw = 1;
+ }
+ #endif
rcCaret.top = rcCaret.bottom - 2;
rcCaret.left = xposCaret + 1;
- rcCaret.right = rcCaret.left + widthOverstrikeCaret -
1;
+ rcCaret.right = rcCaret.left + (widthOverstrikeCaret *
numCharsToDraw) - 1;
} else if (vsDraw.caretStyle == CARETSTYLE_BLOCK) {
/* Block caret */
rcCaret.left = xposCaret;
------------------------------------------------------------------------------------------------------------------------------
--
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scintilla-interest+***@googlegroups.com.
To post to this group, send email to scintilla-***@googlegroups.com.
Visit this group at http://groups.google.com/group/scintilla-interest.
For more options, visit https://groups.google.com/d/optout.
Neil Hodgson
2014-07-06 00:46:15 UTC
Permalink
Post by johnsonj
I don't why exactly but it works.
When asking for the positions of a particular string, some platforms report the full length for byte 1 and others split the width up between bytes. For example a three byte character may return positions [21, 21, 21] or [7, 14, 21].
Post by johnsonj
please have a look.
thanks
-------------------------------------------------------------------------------------------------------
--- ../scintilla/src/Editor.cxx 2014-06-16 10:39:28.000000000 +0900
+++ Editor.cxx 2014-07-05 16:04:39.128083892 +0900
@@ -3432,9 +3432,20 @@
rcCaret.right = rcCaret.left + vsDraw.caretWidth;
} else if (inOverstrike && drawOverstrikeCaret) {
/* Overstrike (insert mode), use a modified bar caret */
+ #ifdef _WIN32 //by johnsonj
+ int numCharsToDraw = 1;
+ #else
+ int posBefore =posCaret.Position();
+ int posAfter = MovePositionOutsideChar(posBefore + 1, 1);
+ int numCharsToDraw = 1;
+ numCharsToDraw = posAfter - posBefore;
+ if (numCharsToDraw == 0) {
+ numCharsToDraw = 1;
+ }
+ #endif
rcCaret.top = rcCaret.bottom - 2;
rcCaret.left = xposCaret + 1;
- rcCaret.right = rcCaret.left + widthOverstrikeCaret - 1;
+ rcCaret.right = rcCaret.left + (widthOverstrikeCaret * numCharsToDraw) - 1;
This is assuming fixed width characters and is undoing the determination of the width earlier in the code. Look at the code block above this where widthOverstrikeCaret is calculated. Your case is probably the third clause of the if: ll->positions[offset + 1] - ll->positions[offset]. What you probably want is to plug in the character width in bytes instead of '1' here.

Neil
--
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scintilla-interest+***@googlegroups.com.
To post to this group, send email to scintilla-***@googlegroups.com.
Visit this group at http://groups.google.com/group/scintilla-interest.
For more options, visit https://groups.google.com/d/optout.
johnsonj
2014-07-07 01:41:18 UTC
Permalink
The code above is copide from void Editor::DrawBlockCaret(): the first
three lines.
The calculation of the overstrike caret widthe should be same as void
Editor::DrawBlockCaret().
--
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scintilla-interest+***@googlegroups.com.
To post to this group, send email to scintilla-***@googlegroups.com.
Visit this group at http://groups.google.com/group/scintilla-interest.
For more options, visit https://groups.google.com/d/optout.
Neil Hodgson
2014-07-07 03:20:02 UTC
Permalink
The code above is copide from void Editor::DrawBlockCaret(): the first three lines.
The calculation of the overstrike caret widthe should be same as void Editor::DrawBlockCaret().
In DrawBlockCaret, the result of the first three lines is then used to index into the positions array to find the real width. The results are never used to simply multiply the width of the first byte.

Also, the "#ifdef _WIN32" is a good indication that something hasn't been written in a portable way - there are 4 platforms supported by the core distribution of Scintilla and several more distributed by others. Some of these platforms run on multiple operating systems - your #ifdef will cause different behaviour in GTK+ on Windows than GTK+ on X/Linux or GTK+ on OS X.

Platform #if tests should only be used in extreme situations and with a lot of thought.

Neil
--
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scintilla-interest+***@googlegroups.com.
To post to this group, send email to scintilla-***@googlegroups.com.
Visit this group at http://groups.google.com/group/scintilla-interest.
For more options, visit https://groups.google.com/d/optout.
johnsonj
2014-07-07 04:05:34 UTC
Permalink
I don't ask you to admit this patch.
It just shows the overstrike caret width on gtk is shorter than 1 character
width, just same as 1 byte width.
It works on win32. and block caret width is same wide on both win32 and
gtk2.0.
so, I think the solution is in drawBlockCaret().
I just here show the problem and the solution.

I have no ability to handle this.

There will come someon who knows all the 4 platforms completly.
I just hope maybe he will fix this.
--
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scintilla-interest+***@googlegroups.com.
To post to this group, send email to scintilla-***@googlegroups.com.
Visit this group at http://groups.google.com/group/scintilla-interest.
For more options, visit https://groups.google.com/d/optout.
Neil Hodgson
2014-07-09 06:52:22 UTC
Permalink
This patch may fix the problem with the caret being too narrow on GTK+.
https://sourceforge.net/p/scintilla/code/ci/c3c75434303aee12a36100d01604016ced74c174/
Due to the code refactoring after 3.4.4 was released, this patch can not be directly applied to 3.4.4 as it is in the new EditView.cxx file.

Neil
--
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scintilla-interest+***@googlegroups.com.
To post to this group, send email to scintilla-***@googlegroups.com.
Visit this group at http://groups.google.com/group/scintilla-interest.
For more options, visit https://groups.google.com/d/optout.
Loading...