cursor shape setting (fixes #55)

This commit is contained in:
Eugene Pankov 2017-07-25 19:36:28 +02:00
parent 9bee253dd0
commit 0fe2de591a
4 changed files with 80 additions and 20 deletions

View File

@ -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

View File

@ -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 () {

View File

@ -8,6 +8,7 @@ export class TerminalConfigProvider extends ConfigProvider {
bracketedPaste: false,
background: 'theme',
ligatures: false,
cursor: 'block',
colorScheme: {
__nonStructural: true,
name: 'Material',

View File

@ -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()
}