diff --git a/terminus-terminal/src/components/terminalSettingsTab.component.pug b/terminus-terminal/src/components/terminalSettingsTab.component.pug index ab915358..4722cdaa 100644 --- a/terminus-terminal/src/components/terminalSettingsTab.component.pug +++ b/terminus-terminal/src/components/terminalSettingsTab.component.pug @@ -174,26 +174,53 @@ [title]='idx', ) - .form-group - label Terminal background - br - div( - '[(ngModel)]'='config.store.terminal.background', - (ngModelChange)='config.save()', - ngbRadioGroup - ) - label.btn.btn-secondary - input( - type='radio', - [value]='"theme"' - ) - | From theme - label.btn.btn-secondary - input( - type='radio', - [value]='"colorScheme"' - ) - | From colors + .d-flex + .form-group.mr-3 + label Terminal background + br + div( + '[(ngModel)]'='config.store.terminal.background', + (ngModelChange)='config.save()', + ngbRadioGroup + ) + label.btn.btn-secondary + input( + type='radio', + [value]='"theme"' + ) + | From theme + label.btn.btn-secondary + input( + type='radio', + [value]='"colorScheme"' + ) + | From colors + .form-group + label Cursor shape + br + div( + [(ngModel)]='config.store.terminal.cursor', + (ngModelChange)='config.save()', + ngbRadioGroup + ) + label.btn.btn-secondary + input( + type='radio', + [value]='"block"' + ) + | Block + label.btn.btn-secondary + input( + type='radio', + [value]='"underline"' + ) + | Underline + label.btn.btn-secondary + input( + type='radio', + [value]='"beam"' + ) + | Beam .form-group label Shell diff --git a/terminus-terminal/src/components/terminalTab.component.ts b/terminus-terminal/src/components/terminalTab.component.ts index 5a662ad3..e93a1f88 100644 --- a/terminus-terminal/src/components/terminalTab.component.ts +++ b/terminus-terminal/src/components/terminalTab.component.ts @@ -299,6 +299,12 @@ export class TerminalTabComponent extends BaseTabComponent { css += config.appearance.css this.hterm.setCSS(css) this.hterm.setBracketedPaste(config.terminal.bracketedPaste) + this.hterm.defaultCursorShape = { + block: hterm.hterm.Terminal.cursorShape.BLOCK, + underline: hterm.hterm.Terminal.cursorShape.UNDERLINE, + beam: hterm.hterm.Terminal.cursorShape.BEAM, + }[config.terminal.cursor] + this.hterm.applyCursorShape() } zoomIn () { diff --git a/terminus-terminal/src/config.ts b/terminus-terminal/src/config.ts index f36103bb..35e96206 100644 --- a/terminus-terminal/src/config.ts +++ b/terminus-terminal/src/config.ts @@ -8,6 +8,7 @@ export class TerminalConfigProvider extends ConfigProvider { bracketedPaste: false, background: 'theme', ligatures: false, + cursor: 'block', colorScheme: { __nonStructural: true, name: 'Material', diff --git a/terminus-terminal/src/hterm.ts b/terminus-terminal/src/hterm.ts index 6ce77d4b..4f76c629 100644 --- a/terminus-terminal/src/hterm.ts +++ b/terminus-terminal/src/hterm.ts @@ -40,3 +40,29 @@ hterm.lib.wc.charWidthDisregardAmbiguous = codepoint => { } return oldCharWidthDisregardAmbiguous(codepoint) } + +hterm.hterm.Terminal.prototype.applyCursorShape = function () { + let modes = [ + [hterm.hterm.Terminal.cursorShape.BLOCK, true], + [this.defaultCursorShape || hterm.hterm.Terminal.cursorShape.BLOCK, false], + [hterm.hterm.Terminal.cursorShape.BLOCK, false], + [hterm.hterm.Terminal.cursorShape.UNDERLINE, true], + [hterm.hterm.Terminal.cursorShape.UNDERLINE, false], + [hterm.hterm.Terminal.cursorShape.BEAM, true], + [hterm.hterm.Terminal.cursorShape.BEAM, false], + ] + let modeNumber = this.cursorMode || 1 + console.log('mode', modeNumber) + if (modeNumber >= modes.length) { + console.warn('Unknown cursor style: ' + modeNumber) + return + } + this.setCursorShape(modes[modeNumber][0]) + this.setCursorBlink(modes[modeNumber][1]) +} + +hterm.hterm.VT.CSI[' q'] = function (parseState) { + const arg = parseState.args[0] + this.terminal.cursorMode = arg + this.terminal.applyCursorShape() +}