Browse Source

TextArea.IsInputChar now always returns true. This fixes SD2-747: Form containing the text editor and a button with a shortcut

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1916 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 20 years ago
parent
commit
dfe345a6f8
  1. 108
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/GutterMargin.cs
  2. 33
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextArea.cs

108
src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/GutterMargin.cs

@ -95,67 +95,67 @@ namespace ICSharpCode.TextEditor @@ -95,67 +95,67 @@ namespace ICSharpCode.TextEditor
public override void HandleMouseDown(Point mousepos, MouseButtons mouseButtons)
{
Point selectionStartPos;
Point selectionStartPos;
textArea.SelectionManager.selectFrom.where = WhereFrom.Gutter;
textArea.SelectionManager.selectFrom.where = WhereFrom.Gutter;
int realline = textArea.TextView.GetLogicalLine(mousepos);
if (realline >= 0 && realline < textArea.Document.TotalNumberOfLines) {
// shift-select
// shift-select
if((Control.ModifierKeys & Keys.Shift) != 0) {
if(!textArea.SelectionManager.HasSomethingSelected && realline != textArea.Caret.Position.Y) {
if (realline >= textArea.Caret.Position.Y)
{ // at or below starting selection, place the cursor on the next line
// nothing is selected so make a new selection from cursor
selectionStartPos = textArea.Caret.Position;
// whole line selection - start of line to start of next line
if (realline < textArea.Document.TotalNumberOfLines - 1)
{
textArea.SelectionManager.SetSelection(new DefaultSelection(textArea.Document, selectionStartPos, new Point(0, realline + 1)));
textArea.Caret.Position = new Point(0, realline + 1);
}
else
{
textArea.SelectionManager.SetSelection(new DefaultSelection(textArea.Document, selectionStartPos, new Point(textArea.Document.GetLineSegment(realline).Length + 1, realline)));
textArea.Caret.Position = new Point(textArea.Document.GetLineSegment(realline).Length + 1, realline);
}
}
else
{ // prior lines to starting selection, place the cursor on the same line as the new selection
// nothing is selected so make a new selection from cursor
selectionStartPos = textArea.Caret.Position;
// whole line selection - start of line to start of next line
textArea.SelectionManager.SetSelection(new DefaultSelection(textArea.Document, selectionStartPos, new Point(selectionStartPos.X, selectionStartPos.Y)));
textArea.SelectionManager.ExtendSelection(new Point(selectionStartPos.X, selectionStartPos.Y), new Point(0, realline));
textArea.Caret.Position = new Point(0, realline);
}
}
else
{
// let MouseMove handle a shift-click in a gutter
MouseEventArgs e = new MouseEventArgs(mouseButtons, 1, mousepos.X, mousepos.Y, 0);
textArea.doMouseMove(e);
}
if(!textArea.SelectionManager.HasSomethingSelected && realline != textArea.Caret.Position.Y) {
if (realline >= textArea.Caret.Position.Y)
{ // at or below starting selection, place the cursor on the next line
// nothing is selected so make a new selection from cursor
selectionStartPos = textArea.Caret.Position;
// whole line selection - start of line to start of next line
if (realline < textArea.Document.TotalNumberOfLines - 1)
{
textArea.SelectionManager.SetSelection(new DefaultSelection(textArea.Document, selectionStartPos, new Point(0, realline + 1)));
textArea.Caret.Position = new Point(0, realline + 1);
}
else
{
textArea.SelectionManager.SetSelection(new DefaultSelection(textArea.Document, selectionStartPos, new Point(textArea.Document.GetLineSegment(realline).Length + 1, realline)));
textArea.Caret.Position = new Point(textArea.Document.GetLineSegment(realline).Length + 1, realline);
}
}
else
{ // prior lines to starting selection, place the cursor on the same line as the new selection
// nothing is selected so make a new selection from cursor
selectionStartPos = textArea.Caret.Position;
// whole line selection - start of line to start of next line
textArea.SelectionManager.SetSelection(new DefaultSelection(textArea.Document, selectionStartPos, new Point(selectionStartPos.X, selectionStartPos.Y)));
textArea.SelectionManager.ExtendSelection(new Point(selectionStartPos.X, selectionStartPos.Y), new Point(0, realline));
textArea.Caret.Position = new Point(0, realline);
}
}
else
{
// let MouseMove handle a shift-click in a gutter
MouseEventArgs e = new MouseEventArgs(mouseButtons, 1, mousepos.X, mousepos.Y, 0);
textArea.RaiseMouseMove(e);
}
} else { // this is a new selection with no shift-key
// sync the textareamousehandler mouse location
// (fixes problem with clicking out into a menu then back to the gutter whilst
// there is a selection)
textArea.mousepos = mousepos;
// sync the textareamousehandler mouse location
// (fixes problem with clicking out into a menu then back to the gutter whilst
// there is a selection)
textArea.mousepos = mousepos;
selectionStartPos = new Point(0, realline);
selectionStartPos = new Point(0, realline);
textArea.SelectionManager.ClearSelection();
// whole line selection - start of line to start of next line
if (realline < textArea.Document.TotalNumberOfLines - 1)
{
textArea.SelectionManager.SetSelection(new DefaultSelection(textArea.Document, selectionStartPos, new Point(selectionStartPos.X, selectionStartPos.Y + 1)));
textArea.Caret.Position = new Point(selectionStartPos.X, selectionStartPos.Y + 1);
}
else
{
textArea.SelectionManager.SetSelection(new DefaultSelection(textArea.Document, new Point(0, realline), new Point(textArea.Document.GetLineSegment(realline).Length + 1, selectionStartPos.Y)));
textArea.Caret.Position = new Point(textArea.Document.GetLineSegment(realline).Length + 1, selectionStartPos.Y);
}
}
// whole line selection - start of line to start of next line
if (realline < textArea.Document.TotalNumberOfLines - 1)
{
textArea.SelectionManager.SetSelection(new DefaultSelection(textArea.Document, selectionStartPos, new Point(selectionStartPos.X, selectionStartPos.Y + 1)));
textArea.Caret.Position = new Point(selectionStartPos.X, selectionStartPos.Y + 1);
}
else
{
textArea.SelectionManager.SetSelection(new DefaultSelection(textArea.Document, new Point(0, realline), new Point(textArea.Document.GetLineSegment(realline).Length + 1, selectionStartPos.Y)));
textArea.Caret.Position = new Point(textArea.Document.GetLineSegment(realline).Length + 1, selectionStartPos.Y);
}
}
}
}
}
}
}

33
src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextArea.cs

@ -56,8 +56,8 @@ namespace ICSharpCode.TextEditor @@ -56,8 +56,8 @@ namespace ICSharpCode.TextEditor
SelectionManager selectionManager;
Caret caret;
public Point mousepos = new Point(0, 0);
//public Point selectionStartPos = new Point(0,0);
internal Point mousepos = new Point(0, 0);
//public Point selectionStartPos = new Point(0,0);
bool disposed;
@ -301,11 +301,11 @@ namespace ICSharpCode.TextEditor @@ -301,11 +301,11 @@ namespace ICSharpCode.TextEditor
protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e)
{
// this corrects weird problems when text is selected,
// then a menu item is selected, then the text is
// clicked again - it correctly synchronises the
// click position
mousepos = new Point(e.X, e.Y);
// this corrects weird problems when text is selected,
// then a menu item is selected, then the text is
// clicked again - it correctly synchronises the
// click position
mousepos = new Point(e.X, e.Y);
base.OnMouseDown(e);
CloseToolTip();
@ -315,7 +315,7 @@ namespace ICSharpCode.TextEditor @@ -315,7 +315,7 @@ namespace ICSharpCode.TextEditor
margin.HandleMouseDown(new Point(e.X, e.Y), e.Button);
}
}
}
}
// static because the mouse can only be in one text area and we don't want to have
@ -412,13 +412,13 @@ namespace ICSharpCode.TextEditor @@ -412,13 +412,13 @@ namespace ICSharpCode.TextEditor
}
}
// external interface to the attached event
public void doMouseMove(System.Windows.Forms.MouseEventArgs e)
{
OnMouseMove(e);
}
// external interface to the attached event
internal void RaiseMouseMove(MouseEventArgs e)
{
OnMouseMove(e);
}
protected override void OnMouseMove(MouseEventArgs e)
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
if (!toolTipRectangle.Contains(e.Location)) {
@ -547,6 +547,11 @@ namespace ICSharpCode.TextEditor @@ -547,6 +547,11 @@ namespace ICSharpCode.TextEditor
return false;
}
protected override bool IsInputChar(char charCode)
{
return true;
}
public void SimulateKeyPress(char ch)
{
if (Document.ReadOnly) {

Loading…
Cancel
Save