mirror of
https://codeberg.org/emersion/gamja.git
synced 2024-11-14 19:05:01 -05:00
Display persistant command input on server buffer
This commit changes the composer to not be read-only on the server buffer, which tells the user that they can send commands from that view. On the server buffer, the placeholder is changed to "Type a command (see /help)", which indicates to the user that this buffer only accepts commands, and gives them a hint for how to learn what commands are available. Implements: https://todo.sr.ht/~emersion/gamja/38
This commit is contained in:
parent
b11f58b975
commit
0b59cf92b9
2 changed files with 13 additions and 5 deletions
|
@ -1759,13 +1759,15 @@ export default class App extends Component {
|
|||
}
|
||||
|
||||
let composerReadOnly = false;
|
||||
if (activeBuffer && activeBuffer.type === BufferType.SERVER) {
|
||||
composerReadOnly = true;
|
||||
}
|
||||
if (activeServer && activeServer.status !== ServerStatus.REGISTERED) {
|
||||
composerReadOnly = true;
|
||||
}
|
||||
|
||||
let commandOnly = false
|
||||
if (activeBuffer && activeBuffer.type === BufferType.SERVER) {
|
||||
commandOnly = true
|
||||
}
|
||||
|
||||
return html`
|
||||
<section
|
||||
id="buffer-list"
|
||||
|
@ -1813,6 +1815,7 @@ export default class App extends Component {
|
|||
readOnly=${composerReadOnly}
|
||||
onSubmit=${this.handleComposerSubmit}
|
||||
autocomplete=${this.autocomplete}
|
||||
commandOnly=${commandOnly}
|
||||
/>
|
||||
${dialog}
|
||||
${error}
|
||||
|
|
|
@ -143,7 +143,7 @@ export default class Composer extends Component {
|
|||
return;
|
||||
}
|
||||
|
||||
if (this.props.readOnly && event.key !== "/") {
|
||||
if (this.props.readOnly || (this.props.commandOnly && event.key !== "/")) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -201,6 +201,11 @@ export default class Composer extends Component {
|
|||
className = "read-only";
|
||||
}
|
||||
|
||||
let placeholder = "Type a message";
|
||||
if (this.props.commandOnly) {
|
||||
placeholder = "Type a command (see /help)";
|
||||
}
|
||||
|
||||
return html`
|
||||
<form
|
||||
id="composer"
|
||||
|
@ -214,7 +219,7 @@ export default class Composer extends Component {
|
|||
ref=${this.textInput}
|
||||
value=${this.state.text}
|
||||
autocomplete="off"
|
||||
placeholder="Type a message"
|
||||
placeholder=${placeholder}
|
||||
enterkeyhint="send"
|
||||
onKeyDown=${this.handleInputKeyDown}
|
||||
/>
|
||||
|
|
Loading…
Reference in a new issue