tab completion

This commit is contained in:
Alberto Xamin 2023-05-05 20:12:55 +02:00 committed by Alberto Xamin
parent 14534997e8
commit a6029cdb0d

View File

@ -21,7 +21,8 @@
@click="fillCmd(msg.cmd)">{{msg.cmd}} <i class="std-text" style="font-size:8pt;">{{msg.help}}</i></p> @click="fillCmd(msg.cmd)">{{msg.cmd}} <i class="std-text" style="font-size:8pt;">{{msg.help}}</i></p>
</div> </div>
<form @submit="sendChatMessage" id="msg-form"> <form @submit="sendChatMessage" id="msg-form">
<input id="my-msg" autocomplete="off" v-model="text" style="flex-grow:2;"/> <input id="my-msg" autocomplete="off" v-model="text" style="flex-grow:2;"
@keydown.tab.prevent="tabComplete($event.target.value)"/>
<input id="submit-message" type="submit" class="btn" :value="$t('submit')"/> <input id="submit-message" type="submit" class="btn" :value="$t('submit')"/>
</form> </form>
</div> </div>
@ -164,6 +165,12 @@ export default {
this.text = cmd; this.text = cmd;
document.getElementById('my-msg').focus(); document.getElementById('my-msg').focus();
}, },
tabComplete() {
if (this.commandSuggestion.length > 0) {
let cmd = this.commandSuggestion[0].cmd;
this.text = cmd + ' ';
}
},
playEffects(path) { playEffects(path) {
const promise = (new Audio(path)).play(); const promise = (new Audio(path)).play();
if(promise !== undefined){ if(promise !== undefined){