mirror of
https://git.proxmox.com/git/mirror_xterm.js
synced 2025-10-19 07:09:14 +00:00
Fix #488: Implement configurable tab width
This commit is contained in:
parent
1c759f1d6f
commit
f4293a6dfa
@ -17,10 +17,13 @@
|
|||||||
<div>
|
<div>
|
||||||
<h2>Options</h2>
|
<h2>Options</h2>
|
||||||
<p>
|
<p>
|
||||||
<label><input type="checkbox" id="option-cursor-blink"> cursorBlink</label>
|
<label>cursorBlink <input type="checkbox" id="option-cursor-blink"></label>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<label>Scrollback <input type="number" id="option-scrollback" value="1000" /></label>
|
<label>scrollback <input type="number" id="option-scrollback" value="1000" /></label>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<label>tabStopWidth <input type="number" id="option-tabstopwidth" value="4" /></label>
|
||||||
</p>
|
</p>
|
||||||
<div>
|
<div>
|
||||||
<h3>Size</h3>
|
<h3>Size</h3>
|
||||||
|
12
demo/main.js
12
demo/main.js
@ -9,7 +9,8 @@ var term,
|
|||||||
var terminalContainer = document.getElementById('terminal-container'),
|
var terminalContainer = document.getElementById('terminal-container'),
|
||||||
optionElements = {
|
optionElements = {
|
||||||
cursorBlink: document.querySelector('#option-cursor-blink'),
|
cursorBlink: document.querySelector('#option-cursor-blink'),
|
||||||
scrollback: document.querySelector('#option-scrollback')
|
scrollback: document.querySelector('#option-scrollback'),
|
||||||
|
tabstopwidth: document.querySelector('#option-tabstopwidth')
|
||||||
},
|
},
|
||||||
colsElement = document.getElementById('cols'),
|
colsElement = document.getElementById('cols'),
|
||||||
rowsElement = document.getElementById('rows');
|
rowsElement = document.getElementById('rows');
|
||||||
@ -32,7 +33,11 @@ optionElements.cursorBlink.addEventListener('change', function () {
|
|||||||
term.setOption('cursorBlink', optionElements.cursorBlink.checked);
|
term.setOption('cursorBlink', optionElements.cursorBlink.checked);
|
||||||
});
|
});
|
||||||
optionElements.scrollback.addEventListener('change', function () {
|
optionElements.scrollback.addEventListener('change', function () {
|
||||||
terminal.setOption('scrollback', parseInt(optionElements.scrollback.value, 10));
|
term.setOption('scrollback', parseInt(optionElements.scrollback.value, 10));
|
||||||
|
});
|
||||||
|
optionElements.tabstopwidth.addEventListener('change', function () {
|
||||||
|
term.setOption('tabStopWidth', parseInt(optionElements.tabstopwidth.value));
|
||||||
|
term.setupStops();
|
||||||
});
|
});
|
||||||
|
|
||||||
createTerminal();
|
createTerminal();
|
||||||
@ -44,7 +49,8 @@ function createTerminal() {
|
|||||||
}
|
}
|
||||||
term = new Terminal({
|
term = new Terminal({
|
||||||
cursorBlink: optionElements.cursorBlink.checked,
|
cursorBlink: optionElements.cursorBlink.checked,
|
||||||
scrollback: parseInt(optionElements.scrollback.value, 10)
|
scrollback: parseInt(optionElements.scrollback.value, 10),
|
||||||
|
tabStopWidth: parseInt(optionElements.tabstopwidth.value)
|
||||||
});
|
});
|
||||||
term.on('resize', function (size) {
|
term.on('resize', function (size) {
|
||||||
if (!pid) {
|
if (!pid) {
|
||||||
|
@ -360,7 +360,8 @@ Terminal.defaults = {
|
|||||||
screenKeys: false,
|
screenKeys: false,
|
||||||
debug: false,
|
debug: false,
|
||||||
cancelEvents: false,
|
cancelEvents: false,
|
||||||
disableStdin: false
|
disableStdin: false,
|
||||||
|
tabStopWidth: 8
|
||||||
// programFeatures: false,
|
// programFeatures: false,
|
||||||
// focusKeys: false,
|
// focusKeys: false,
|
||||||
};
|
};
|
||||||
@ -2118,7 +2119,7 @@ Terminal.prototype.setupStops = function(i) {
|
|||||||
i = 0;
|
i = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; i < this.cols; i += 8) {
|
for (; i < this.cols; i += this.getOption('tabStopWidth')) {
|
||||||
this.tabs[i] = true;
|
this.tabs[i] = true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user