-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Implement configurable tab stop width #497
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,10 +17,13 @@ <h1>xterm.js: xterm, in the browser</h1> | |
| <div> | ||
| <h2>Options</h2> | ||
| <p> | ||
| <label><input type="checkbox" id="option-cursor-blink"> cursorBlink</label> | ||
| <label>cursorBlink <input type="checkbox" id="option-cursor-blink"></label> | ||
| </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> | ||
| <div> | ||
| <h3>Size</h3> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,7 +9,8 @@ var term, | |
| var terminalContainer = document.getElementById('terminal-container'), | ||
| optionElements = { | ||
| 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'), | ||
| rowsElement = document.getElementById('rows'); | ||
|
|
@@ -32,7 +33,10 @@ optionElements.cursorBlink.addEventListener('change', function () { | |
| term.setOption('cursorBlink', optionElements.cursorBlink.checked); | ||
| }); | ||
| 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)); | ||
|
||
| }); | ||
|
|
||
| createTerminal(); | ||
|
|
@@ -44,7 +48,8 @@ function createTerminal() { | |
| } | ||
| term = new Terminal({ | ||
| 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) { | ||
| if (!pid) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -360,7 +360,8 @@ Terminal.defaults = { | |
| screenKeys: false, | ||
| debug: false, | ||
| cancelEvents: false, | ||
| disableStdin: false | ||
| disableStdin: false, | ||
| tabStopWidth: 8 | ||
| // programFeatures: false, | ||
| // focusKeys: false, | ||
| }; | ||
|
|
@@ -433,6 +434,7 @@ Terminal.prototype.setOption = function(key, value) { | |
| this.element.classList.toggle(`xterm-cursor-style-underline`, value === 'underline'); | ||
| this.element.classList.toggle(`xterm-cursor-style-bar`, value === 'bar'); | ||
| break; | ||
| case 'tabStopWidth': this.setupStops(); break; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Eventually we could move this to event listeners which would probably be a better structure.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep. It does the job for now, so let's keep this for another PR. |
||
| } | ||
| }; | ||
|
|
||
|
|
@@ -2118,7 +2120,7 @@ Terminal.prototype.setupStops = function(i) { | |
| i = 0; | ||
| } | ||
|
|
||
| for (; i < this.cols; i += 8) { | ||
| for (; i < this.cols; i += this.getOption('tabStopWidth')) { | ||
| this.tabs[i] = true; | ||
| } | ||
| }; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Normally checkboxes are at the start of the line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did this to keep uniformity with the rest. Will revert.