Expose API on Terminal

This commit is contained in:
Daniel Imms 2017-06-13 19:49:12 -07:00
parent 7d8f698096
commit f88dcd160c
2 changed files with 24 additions and 3 deletions

View File

@ -22,7 +22,7 @@ export class SearchHelper {
*/
public findNext(term: string): boolean {
if (!term || term.length === 0) {
return;
return false;
}
let result: ISearchResult;
@ -63,7 +63,7 @@ export class SearchHelper {
*/
public findPrevious(term: string): boolean {
if (!term || term.length === 0) {
return;
return false;
}
let result: ISearchResult;
@ -111,10 +111,11 @@ export class SearchHelper {
private _selectResult(result: ISearchResult): boolean {
if (!result) {
return;
return false;
}
this._terminal.selectionManager.setSelection(result.col, result.row, result.term.length);
this._terminal.scrollDisp(result.row - this._terminal.ydisp, false);
return true;
}
// TODO: Consolidate with SelectionManager function

View File

@ -1405,6 +1405,26 @@ Terminal.prototype.selectAll = function() {
this.selectionManager.selectAll();
}
/**
* Find the next instance of the term, then scroll to and select it. If it
* doesn't exist, do nothing.
* @param term The term to search for.
* @return Whether a result was found.
*/
Terminal.prototype.findNext = function(term) {
return this.searchHelper.findNext(term);
}
/**
* Find the previous instance of the term, then scroll to and select it. If it
* doesn't exist, do nothing.
* @param term The term to search for.
* @return Whether a result was found.
*/
Terminal.prototype.findPrevious = function(term) {
return this.searchHelper.findPrevious(term);
}
/**
* Handle a keydown event
* Key Resources: