From 4b0cf2ffcecf9eac6f607a2b5ce213001f48d497 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Sun, 9 Jul 2017 00:36:15 -0700 Subject: [PATCH] jsdoc --- src/addons/search/search.ts | 4 ++-- src/addons/search/searchHelper.ts | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/addons/search/search.ts b/src/addons/search/search.ts index 8585889d..5a227a8a 100644 --- a/src/addons/search/search.ts +++ b/src/addons/search/search.ts @@ -32,7 +32,7 @@ declare var window: any; /** * 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. + * @param term Tne search term. * @return Whether a result was found. */ Terminal.prototype.findNext = function(term: string): boolean { @@ -45,7 +45,7 @@ declare var window: any; /** * 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. + * @param term Tne search term. * @return Whether a result was found. */ Terminal.prototype.findPrevious = function(term: string): boolean { diff --git a/src/addons/search/searchHelper.ts b/src/addons/search/searchHelper.ts index 6f88e04b..f2851447 100644 --- a/src/addons/search/searchHelper.ts +++ b/src/addons/search/searchHelper.ts @@ -11,6 +11,9 @@ interface ISearchResult { row: number; } +/** + * A class that knows how to search the terminal and how to display the results. + */ export class SearchHelper { constructor(private _terminal: any, private _translateBufferLineToString: any) { // TODO: Search for multiple instances on 1 line @@ -22,7 +25,7 @@ export class SearchHelper { /** * 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. + * @param term Tne search term. * @return Whether a result was found. */ public findNext(term: string): boolean { @@ -63,7 +66,7 @@ export class SearchHelper { /** * 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. + * @param term Tne search term. * @return Whether a result was found. */ public findPrevious(term: string): boolean { @@ -101,6 +104,12 @@ export class SearchHelper { return this._selectResult(result); } + /** + * Searches a line for a search term. + * @param term Tne search term. + * @param y The line to search. + * @return The search result if it was found. + */ private _findInLine(term: string, y: number): ISearchResult { const bufferLine = this._terminal.lines.get(y); const lowerStringLine = this._translateBufferLineToString(bufferLine, true).toLowerCase(); @@ -115,6 +124,11 @@ export class SearchHelper { } } + /** + * Selects and scrolls to a result. + * @param result The result to select. + * @return Whethera result was selected. + */ private _selectResult(result: ISearchResult): boolean { if (!result) { return false;