Browse Source

Fix caret rendering in overstrike mode on right-to-left text.

pull/331/head
Daniel Grunwald 12 years ago
parent
commit
9cf768e802
  1. 6
      data/resources/StringResources.resx
  2. 7
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ContextActions/ClipboardRingPopup.cs
  3. 12
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/Caret.cs
  4. 8
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/TextEditorOptions.cs

6
data/resources/StringResources.resx

@ -6437,11 +6437,9 @@ Removed the end part of the original message ", reason '${Message}'" since this @@ -6437,11 +6437,9 @@ Removed the end part of the original message ", reason '${Message}'" since this
<value>Classes deriving from ${Name}</value>
<comment>Title for search results for derived classes</comment>
</data>
<data name="SharpDevelop.Refactoring.ClipboardRing" xml:space="preserve">
<value>Clipboard ring</value>
</data>
<data name="SharpDevelop.Refactoring.ClipboardRingCommand" xml:space="preserve">
<value>From clipboard ring</value>
<value>Paste from clipboard ring...</value>
<comment>'Paste previous' command in Edit &gt; Insert menu</comment>
</data>
<data name="SharpDevelop.Refactoring.ClipboardRingEmpty" xml:space="preserve">
<value>Clipboard ring is empty</value>

7
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ContextActions/ClipboardRingPopup.cs

@ -10,18 +10,21 @@ using ICSharpCode.SharpDevelop.Editor.ContextActions; @@ -10,18 +10,21 @@ using ICSharpCode.SharpDevelop.Editor.ContextActions;
namespace ICSharpCode.AvalonEdit.AddIn.ContextActions
{
/// <summary>
/// 'Paste from clipboard ring' command
/// </summary>
public class ClipboardRingPopup : ContextActionsPopup
{
ToolTip toolTip;
public ClipboardRingPopup() : base()
{
{
this.toolTip = new ToolTip();
this.toolTip.PlacementTarget = this.ActionsControl;
this.toolTip.Placement = PlacementMode.Right;
this.toolTip.Closed += new RoutedEventHandler(ClipboardRingPopup_Closed);
this.ActionsControl.ActionExecuted += delegate
this.ActionsControl.ActionExecuted += delegate
{
if(this.toolTip != null)
this.toolTip.IsOpen = false;

12
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/Caret.cs

@ -389,17 +389,19 @@ namespace ICSharpCode.AvalonEdit.Editing @@ -389,17 +389,19 @@ namespace ICSharpCode.AvalonEdit.Editing
}
TextLine textLine = visualLine.GetTextLine(position.VisualColumn, position.IsAtEndOfLine);
double xPos = visualLine.GetTextLineVisualXPosition(textLine, position.VisualColumn);
double lineTop = visualLine.GetTextLineVisualYPosition(textLine, VisualYPosition.TextTop);
double lineBottom = visualLine.GetTextLineVisualYPosition(textLine, VisualYPosition.TextBottom);
int currentPos = position.VisualColumn;
double xPos = visualLine.GetTextLineVisualXPosition(textLine, currentPos);
// The text being overwritten in overstrike mode is everything up to the next normal caret stop
int nextPos = visualLine.GetNextCaretPosition(currentPos, LogicalDirection.Forward, CaretPositioningMode.Normal, true);
double charSize = Math.Abs(
visualLine.GetTextLineVisualXPosition(textLine, currentPos) -
visualLine.GetTextLineVisualXPosition(textLine, nextPos) );
double nextXPos = visualLine.GetTextLineVisualXPosition(textLine, nextPos);
// Use Math.Abs (and Math.Min below) in case of right-to-left text
// Use a minimum width of SystemParameters.CaretWidth in case of extremely thin characters (e.g. zero-width space)
double charSize = Math.Max(Math.Abs(xPos - nextXPos), SystemParameters.CaretWidth);
return new Rect(xPos,
return new Rect(Math.Min(xPos, nextXPos),
lineTop,
charSize,
lineBottom - lineTop);

8
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/TextEditorOptions.cs

@ -464,10 +464,10 @@ namespace ICSharpCode.AvalonEdit @@ -464,10 +464,10 @@ namespace ICSharpCode.AvalonEdit
bool hideCursorWhileTyping = true;
[DefaultValue(true)]
/// <summary>
/// Gets/Sets if mouse cursor should be shown when user is typing
/// Gets/Sets if mouse cursor should be hidden while user is typing.
/// </summary>
[DefaultValue(true)]
public bool HideCursorWhileTyping {
get { return hideCursorWhileTyping; }
set {
@ -480,10 +480,10 @@ namespace ICSharpCode.AvalonEdit @@ -480,10 +480,10 @@ namespace ICSharpCode.AvalonEdit
bool allowOverstrikeMode = false;
[DefaultValue(false)]
/// <summary>
/// Gets/Sets if overstrike mode is enabled to use
/// Gets/Sets if the user is allowed to switch to overstrike mode.
/// </summary>
[DefaultValue(false)]
public bool AllowOverstrikeMode {
get { return allowOverstrikeMode; }
set {

Loading…
Cancel
Save