hterm: update find bar results

The find bar results are updated when text is modified in terminal.
If selected row is modified the first result of the row is selected.
If no results are present on the row we invalidate the selected result
and total number of matches are shown instead.
E.g. :- '3 matches' instead of showing the selected ordinal
E.g. :- '1/3'.
The position of selected result depends arrow buttons pressed on
FindBar.
When up arrow button is pressed the match just before the cursor is
selected.
Similarly, When down arrow button is pressed the match just after
the cursor is selected.
In both cases, the counter label is reverted to it original state and
shows the selected ordinal E.g. :- '1/3'.

Change-Id: I9c6930d305a85b9f23396076030889aa94f57911
Reviewed-on: https://chromium-review.googlesource.com/c/apps/libapps/+/2305810
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Joel Hockey <joelhockey@chromium.org>
diff --git a/hterm/js/hterm_terminal.js b/hterm/js/hterm_terminal.js
index 9b56980..91514d7 100644
--- a/hterm/js/hterm_terminal.js
+++ b/hterm/js/hterm_terminal.js
@@ -2186,6 +2186,8 @@
 
     this.screen_.maybeClipCurrentRow();
     startOffset += count;
+    this.findBar.scheduleNotifyChanges(
+        this.scrollbackRows_.length + this.screen_.cursorPosition.row);
   }
 
   if (this.scrollOnOutput_) {
@@ -2337,6 +2339,8 @@
   this.setCursorColumn(0);
   const count = cursor.column + 1;
   this.screen_.overwriteString(' '.repeat(count), count);
+    this.findBar.scheduleNotifyChanges(
+        this.scrollbackRows_.length + this.screen_.cursorPosition.row);
   this.restoreCursor(cursor);
 };
 
@@ -2365,6 +2369,9 @@
   const maxCount = this.screenSize.width - this.screen_.cursorPosition.column;
   count = count ? Math.min(count, maxCount) : maxCount;
 
+  this.findBar.scheduleNotifyChanges(
+    this.scrollbackRows_.length + this.screen_.cursorPosition.row);
+
   if (this.screen_.textAttributes.background ===
       this.screen_.textAttributes.DEFAULT_COLOR) {
     const cursorRow = this.screen_.rowsArray[this.screen_.cursorPosition.row];
@@ -2451,6 +2458,7 @@
       this.setAbsoluteCursorPosition(row, col);
       this.screen_.overwriteString(ch, 1);
     }
+    this.findBar.scheduleNotifyChanges(this.scrollbackRows_.length + row);
   }
 
   this.restoreCursor(cursor);
@@ -2574,6 +2582,8 @@
   const ws = ' '.repeat(count || 1);
   this.screen_.insertString(ws, ws.length);
   this.screen_.maybeClipCurrentRow();
+  this.findBar.scheduleNotifyChanges(
+    this.scrollbackRows_.length + this.screen_.cursorPosition.row);
 
   this.restoreCursor(cursor);
   this.clearCursorOverflow();
@@ -2594,6 +2604,8 @@
     this.restoreCursor(cursor);
   }
 
+  this.findBar.scheduleNotifyChanges(
+    this.scrollbackRows_.length + this.screen_.cursorPosition.row);
   this.clearCursorOverflow();
 };