mirror of
https://github.com/atom/atom.git
synced 2026-01-23 13:58:08 -05:00
Merge pull request #17124 from atom/aw/keyboard-enablement
Separate keyboard enablement from read-only editor state
This commit is contained in:
@@ -477,7 +477,7 @@ class TextEditorComponent {
|
||||
attributes.mini = ''
|
||||
}
|
||||
|
||||
if (!this.isInputEnabled()) {
|
||||
if (model.isReadOnly()) {
|
||||
attributes.readonly = ''
|
||||
}
|
||||
|
||||
@@ -2965,11 +2965,11 @@ class TextEditorComponent {
|
||||
}
|
||||
|
||||
setInputEnabled (inputEnabled) {
|
||||
this.props.model.update({readOnly: !inputEnabled})
|
||||
this.props.model.update({keyboardInputEnabled: inputEnabled})
|
||||
}
|
||||
|
||||
isInputEnabled (inputEnabled) {
|
||||
return !this.props.model.isReadOnly()
|
||||
isInputEnabled () {
|
||||
return !this.props.model.isReadOnly() && this.props.model.isKeyboardInputEnabled()
|
||||
}
|
||||
|
||||
getHiddenInput () {
|
||||
|
||||
@@ -107,6 +107,13 @@ class TextEditor {
|
||||
}
|
||||
|
||||
state.assert = atomEnvironment.assert.bind(atomEnvironment)
|
||||
|
||||
// Semantics of the readOnly flag have changed since its introduction.
|
||||
// Only respect readOnly2, which has been set with the current readOnly semantics.
|
||||
delete state.readOnly
|
||||
state.readOnly = state.readOnly2
|
||||
delete state.readOnly2
|
||||
|
||||
const editor = new TextEditor(state)
|
||||
if (state.registered) {
|
||||
const disposable = atomEnvironment.textEditors.add(editor)
|
||||
@@ -130,6 +137,7 @@ class TextEditor {
|
||||
this.decorationManager = params.decorationManager
|
||||
this.selectionsMarkerLayer = params.selectionsMarkerLayer
|
||||
this.mini = (params.mini != null) ? params.mini : false
|
||||
this.keyboardInputEnabled = (params.keyboardInputEnabled != null) ? params.keyboardInputEnabled : true
|
||||
this.readOnly = (params.readOnly != null) ? params.readOnly : false
|
||||
this.placeholderText = params.placeholderText
|
||||
this.showLineNumbers = params.showLineNumbers
|
||||
@@ -416,6 +424,15 @@ class TextEditor {
|
||||
}
|
||||
break
|
||||
|
||||
case 'keyboardInputEnabled':
|
||||
if (value !== this.keyboardInputEnabled) {
|
||||
this.keyboardInputEnabled = value
|
||||
if (this.component != null) {
|
||||
this.component.scheduleUpdate()
|
||||
}
|
||||
}
|
||||
break
|
||||
|
||||
case 'placeholderText':
|
||||
if (value !== this.placeholderText) {
|
||||
this.placeholderText = value
|
||||
@@ -546,7 +563,8 @@ class TextEditor {
|
||||
softWrapAtPreferredLineLength: this.softWrapAtPreferredLineLength,
|
||||
preferredLineLength: this.preferredLineLength,
|
||||
mini: this.mini,
|
||||
readOnly: this.readOnly,
|
||||
readOnly2: this.readOnly, // readOnly encompassed both readOnly and keyboardInputEnabled
|
||||
keyboardInputEnabled: this.keyboardInputEnabled,
|
||||
editorWidthInChars: this.editorWidthInChars,
|
||||
width: this.width,
|
||||
maxScreenLineLength: this.maxScreenLineLength,
|
||||
@@ -988,6 +1006,12 @@ class TextEditor {
|
||||
|
||||
isReadOnly () { return this.readOnly }
|
||||
|
||||
enableKeyboardInput (enabled) {
|
||||
this.update({keyboardInputEnabled: enabled})
|
||||
}
|
||||
|
||||
isKeyboardInputEnabled () { return this.keyboardInputEnabled }
|
||||
|
||||
onDidChangeMini (callback) {
|
||||
return this.emitter.on('did-change-mini', callback)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user