diff --git a/Project/Src/Actions/MiscActions.cs b/Project/Src/Actions/MiscActions.cs
index b509379..566bf3e 100644
--- a/Project/Src/Actions/MiscActions.cs
+++ b/Project/Src/Actions/MiscActions.cs
@@ -655,6 +655,36 @@ public override void Execute(TextArea textArea)
}
}
+ public class Space : AbstractEditAction
+ {
+ ///
+ /// Executes this edit action
+ ///
+ /// The which is used for callback purposes
+ public override void Execute(TextArea textArea)
+ {
+ if (!textArea.Document.ReadOnly)
+ return;
+
+ (new MovePageDown()).Execute(textArea);
+ }
+ }
+
+ public class ShiftSpace : AbstractEditAction
+ {
+ ///
+ /// Executes this edit action
+ ///
+ /// The which is used for callback purposes
+ public override void Execute(TextArea textArea)
+ {
+ if (!textArea.Document.ReadOnly)
+ return;
+
+ (new MovePageUp()).Execute(textArea);
+ }
+ }
+
public class Return : AbstractEditAction
{
///
diff --git a/Project/Src/Gui/TextArea.cs b/Project/Src/Gui/TextArea.cs
index 56e2c24..7fef5fc 100644
--- a/Project/Src/Gui/TextArea.cs
+++ b/Project/Src/Gui/TextArea.cs
@@ -803,7 +803,7 @@ public bool ExecuteDialogKey(Keys keyData)
return true;
// if not (or the process was 'silent', use the standard edit actions
- var action = MotherTextEditorControl?.GetEditAction(keyData);
+ var action = MotherTextEditorControl?.GetEditAction(keyData, Document.ReadOnly);
AutoClearSelection = true;
if (action != null)
{
diff --git a/Project/Src/Gui/TextEditorControlBase.cs b/Project/Src/Gui/TextEditorControlBase.cs
index dcf239a..07aa010 100644
--- a/Project/Src/Gui/TextEditorControlBase.cs
+++ b/Project/Src/Gui/TextEditorControlBase.cs
@@ -37,6 +37,12 @@ public abstract class TextEditorControlBase : UserControl
///
protected Dictionary editactions = new Dictionary();
+ ///
+ /// Key combinations for actions only available in read-only mode.
+ /// In read-write these keys are ignored.
+ ///
+ protected HashSet readonlyactions = new();
+
private Encoding encoding;
private int updateLevel;
@@ -183,14 +189,14 @@ protected virtual void OnReloadHighlighting(object sender, EventArgs e)
}
}
- public bool IsEditAction(Keys keyData)
+ public bool IsEditAction(Keys keyData, bool readOnly)
{
- return editactions.ContainsKey(keyData);
+ return editactions.ContainsKey(keyData) && (readOnly || !readonlyactions.Contains(keyData));
}
- internal IEditAction GetEditAction(Keys keyData)
+ internal IEditAction GetEditAction(Keys keyData, bool readOnly)
{
- if (!IsEditAction(keyData))
+ if (!IsEditAction(keyData, readOnly))
return null;
return editactions[keyData];
}
@@ -231,6 +237,10 @@ private void GenerateDefaultActions()
editactions[Keys.PageUp | Keys.Shift] = new ShiftMovePageUp();
editactions[Keys.PageDown] = new MovePageDown();
editactions[Keys.PageDown | Keys.Shift] = new ShiftMovePageDown();
+ editactions[Keys.Space] = new Space();
+ readonlyactions.Add(Keys.Space);
+ editactions[Keys.Space | Keys.Shift] = new ShiftSpace();
+ readonlyactions.Add(Keys.Space | Keys.Shift);
editactions[Keys.Return] = new Return();
editactions[Keys.Tab] = new Tab();