1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-09 03:52:19 +02:00

Merge pull request #988 from EinBurgbauer/editwidget-readonly-fix

fix readonly editwidget deletion
This commit is contained in:
Brian Fiete 2021-04-04 06:47:12 -04:00 committed by GitHub
commit f34424a61d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1700,29 +1700,29 @@ namespace Beefy.widgets
if (keyChar == '\x7F') // Ctrl+Backspace if (keyChar == '\x7F') // Ctrl+Backspace
{ {
int line; if (!CheckReadOnly())
int lineChar; {
GetCursorLineChar(out line, out lineChar); int line;
int lineChar;
GetCursorLineChar(out line, out lineChar);
int startIdx = CursorTextPos; int startIdx = CursorTextPos;
SelectLeft(line, lineChar, true, false); SelectLeft(line, lineChar, true, false);
mSelection = EditSelection(CursorTextPos, startIdx); mSelection = EditSelection(CursorTextPos, startIdx);
var action = new DeleteSelectionAction(this); var action = new DeleteSelectionAction(this);
action.mMoveCursor = true; action.mMoveCursor = true;
mData.mUndoManager.Add(action); mData.mUndoManager.Add(action);
action.mCursorTextPos = (.)startIdx; action.mCursorTextPos = (.)startIdx;
PhysDeleteSelection(true); PhysDeleteSelection(true);
}
return; return;
} }
char32 useChar = keyChar; char32 useChar = keyChar;
mCursorBlinkTicks = 0; mCursorBlinkTicks = 0;
if (useChar == '\x7F') // Ctrl+Backspace
useChar = '\b';
if (useChar == '\b') if (useChar == '\b')
{ {
@ -2511,32 +2511,35 @@ namespace Beefy.widgets
case KeyCode.Delete: case KeyCode.Delete:
if (mWidgetWindow.IsKeyDown(.Control)) if (mWidgetWindow.IsKeyDown(.Control))
{ {
if (mWidgetWindow.IsKeyDown(.Shift)) if (!CheckReadOnly())
{ {
if (mWidgetWindow.IsKeyDown(.Shift))
{
int startIdx = CursorTextPos;
CursorToLineEnd();
mSelection = EditSelection(CursorTextPos, startIdx);
var action = new DeleteSelectionAction(this);
action.mMoveCursor = true;
mData.mUndoManager.Add(action);
action.mCursorTextPos = (.)startIdx;
PhysDeleteSelection(true);
break;
}
int line;
int lineChar2;
GetCursorLineChar(out line, out lineChar2);
int startIdx = CursorTextPos; int startIdx = CursorTextPos;
CursorToLineEnd(); SelectRight(line, lineChar, true, false);
mSelection = EditSelection(CursorTextPos, startIdx); mSelection = EditSelection(CursorTextPos, startIdx);
var action = new DeleteSelectionAction(this); var action = new DeleteSelectionAction(this);
action.mMoveCursor = true; action.mMoveCursor = true;
mData.mUndoManager.Add(action); mData.mUndoManager.Add(action);
action.mCursorTextPos = (.)startIdx; action.mCursorTextPos = (.)startIdx;
PhysDeleteSelection(true); PhysDeleteSelection(true);
break;
} }
int line;
int lineChar2;
GetCursorLineChar(out line, out lineChar2);
int startIdx = CursorTextPos;
SelectRight(line, lineChar, true, false);
mSelection = EditSelection(CursorTextPos, startIdx);
var action = new DeleteSelectionAction(this);
action.mMoveCursor = true;
mData.mUndoManager.Add(action);
action.mCursorTextPos = (.)startIdx;
PhysDeleteSelection(true);
break; break;
} }