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,19 +1700,22 @@ namespace Beefy.widgets
if (keyChar == '\x7F') // Ctrl+Backspace
{
int line;
int lineChar;
GetCursorLineChar(out line, out lineChar);
if (!CheckReadOnly())
{
int line;
int lineChar;
GetCursorLineChar(out line, out lineChar);
int startIdx = CursorTextPos;
SelectLeft(line, lineChar, true, false);
mSelection = EditSelection(CursorTextPos, startIdx);
int startIdx = CursorTextPos;
SelectLeft(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);
var action = new DeleteSelectionAction(this);
action.mMoveCursor = true;
mData.mUndoManager.Add(action);
action.mCursorTextPos = (.)startIdx;
PhysDeleteSelection(true);
}
return;
}
@ -1721,9 +1724,6 @@ namespace Beefy.widgets
mCursorBlinkTicks = 0;
if (useChar == '\x7F') // Ctrl+Backspace
useChar = '\b';
if (useChar == '\b')
{
if (!CheckReadOnly())
@ -2511,32 +2511,35 @@ namespace Beefy.widgets
case KeyCode.Delete:
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;
CursorToLineEnd();
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;
}
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;
}