patch 9.0.1684: Update libvterm to rev 839

Problem: libvterm slightly outdated
Solution: Update libvterm from rev 818 to rev 839

Notable fix: libvterm now handles DECSM/DECRM with multiple arguents,
so several ncurses programs (e.g. nnn) can enable mouse properly when
run in Vim's terminal in XTerm.

closes: #12746

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
diff --git a/src/libvterm/t/harness.c b/src/libvterm/t/harness.c
index d12c120..5285d94 100644
--- a/src/libvterm/t/harness.c
+++ b/src/libvterm/t/harness.c
@@ -82,6 +82,26 @@
   printf(")");
 }
 
+static VTermColor strpe_color(char **strp)
+{
+  uint8_t r, g, b, idx;
+  int len = 0;
+  VTermColor col;
+
+  if(sscanf(*strp, "rgb(%hhu,%hhu,%hhu)%n", &r, &g, &b, &len) == 3 && len > 0) {
+    *strp += len;
+    vterm_color_rgb(&col, r, g, b);
+  }
+  else if(sscanf(*strp, "idx(%hhu)%n", &idx, &len) == 1 && len > 0) {
+    *strp += len;
+    vterm_color_indexed(&col, idx);
+  }
+  else
+    vterm_color_rgb(&col, 127, 127, 127);
+
+  return col;
+}
+
 static VTerm *vt;
 static VTermState *state;
 static VTermScreen *screen;
@@ -669,7 +689,10 @@
       if(!state) {
         state = vterm_obtain_state(vt);
         vterm_state_set_callbacks(state, &state_cbs, NULL);
-        vterm_state_set_selection_callbacks(state, &selection_cbs, NULL, NULL, 1024);
+        /* In some tests we want to check the behaviour of overflowing the
+         * buffer, so make it nicely small
+         */
+        vterm_state_set_selection_callbacks(state, &selection_cbs, NULL, NULL, 16);
         vterm_state_set_bold_highbright(state, 1);
         vterm_state_reset(state, 1);
       }
@@ -942,6 +965,23 @@
       vterm_screen_flush_damage(screen);
     }
 
+    else if(strstartswith(line, "SETDEFAULTCOL ")) {
+      assert(screen);
+      char *linep = line + 14;
+      while(linep[0] == ' ')
+        linep++;
+      VTermColor fg = strpe_color(&linep);
+      if(linep[0]) {
+        while(linep[0] == ' ')
+          linep++;
+        VTermColor bg = strpe_color(&linep);
+
+        vterm_screen_set_default_colors(screen, &fg, &bg);
+      }
+      else
+        vterm_screen_set_default_colors(screen, &fg, NULL);
+    }
+
     else if(line[0] == '?') {
       if(streq(line, "?cursor")) {
         assert(state);