]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add the \B escape for CLI prompts. Change the default prompts to cli-prompt-redo
authordrh <>
Fri, 10 Apr 2026 20:06:34 +0000 (20:06 +0000)
committerdrh <>
Fri, 10 Apr 2026 20:06:34 +0000 (20:06 +0000)
use &#92;f, &#92;H, and &#92;B.

FossilOrigin-Name: 354325b6f396bda38bbb82e7d38aa50d3d6441e1ebb9b578aed8e0bcf62f9911

manifest
manifest.uuid
src/shell.c.in

index e1b85d02e760223fd6ea245b6bfb10c448dc4735..552e3e4a410eb1bdc0ffd8077434b047cb458c22 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C The\s&#92;H\sescape\son\sa\sprompt\sstring\sfills\sin\swith\sthe\scharacters\sneeded\nto\smake\sthe\sinput\s"complete".\s\sAdd\sthe\sshell_expand_prompt()\sSQL\sfunction\nfor\stesting\spurposes.
-D 2026-04-10T19:33:15.316
+C Add\sthe\s&#92;B\sescape\sfor\sCLI\sprompts.\s\sChange\sthe\sdefault\sprompts\sto\nuse\s&#92;f,\s&#92;H,\sand\s&#92;B.
+D 2026-04-10T20:06:34.810
 F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
@@ -735,7 +735,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c
 F src/resolve.c 928ff887f2a7c64275182060d94d06fdddbe32226c569781cf7e7edc6f58d7fd
 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97
 F src/select.c ffe199f025a0dd74670d2a77232bdea364a4d7b36f32c64a6572d39ba6a11576
-F src/shell.c.in d94e528d5a6ad833228197794d9d6473d51902cc91a37baef0984574650e3896
+F src/shell.c.in ccadf849cfa03871c93f2869e27af177408ad028a4897626a1550d3fdbdcca18
 F src/sqlite.h.in a5605faa9479bbaac16c4ab43eb09ff50632004a8e05084d3fde56063ef73766
 F src/sqlite3.rc 015537e6ac1eec6c7050e17b616c2ffe6f70fca241835a84a4f0d5937383c479
 F src/sqlite3ext.h 1b7a0ee438bb5c2896d0609c537e917d8057b3340f6ad004d2de44f03e3d3cca
@@ -2197,8 +2197,8 @@ F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee
 F tool/warnings.sh a554d13f6e5cf3760f041b87939e3d616ec6961859c3245e8ef701d1eafc2ca2
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
 F tool/winmain.c 00c8fb88e365c9017db14c73d3c78af62194d9644feaf60e220ab0f411f3604c
-P f3354ebf51e684ef680986bef9b606f63786c254f1c8774bcaf7a7f3d0d37056
-R eb9717568ba2a51cead72c45c6debdf8
+P 6aafb76c74b73aafef74250dae9c8cbe73226c0efb606e8f80ea761b3293cf9d
+R 10023fb5872b0939880b2eb9aec2ef11
 U drh
-Z 98b23073eb30db46d4e741688a728681
+Z c3b3ebd71cd1378ad565509dcb2c7b21
 # Remove this line to create a well-formed Fossil manifest.
index 8b5506f1022fe4de74123b9a9125a1c40ed46f4a..2c3268c216f75b89b7e80e905da86239e33dc0be 100644 (file)
@@ -1 +1 @@
-6aafb76c74b73aafef74250dae9c8cbe73226c0efb606e8f80ea761b3293cf9d
+354325b6f396bda38bbb82e7d38aa50d3d6441e1ebb9b578aed8e0bcf62f9911
index 7c3f75b1c3ac84b015e3855aae435387d63de7d7..5170c2dde092ec0b965ed7e78e136b325b1e1f7c 100644 (file)
@@ -940,6 +940,7 @@ static char *expand_prompt(
   int i;
   char c;
   int onoff = 1;
+  int idxSpace = -1;
   for(i=0; zPrompt[i]; i++){
     if( zPrompt[i]!='\\' ) continue;
     if( i>0 ){
@@ -1072,6 +1073,16 @@ static char *expand_prompt(
       continue;
     }
 
+    if( c=='B' ){
+      /* \B is a no-op for the main prmopt.  For the continuation prompt,
+      ** \B expands to zero or more spaces to make the continuation prompt
+      ** at least as wide as the main prompt. */
+      if( onoff ) idxSpace = sqlite3_str_length(pOut);
+      zPrompt += 2;
+      i = -1;
+      continue;
+    }
+
     /* No match to a known escape.  Generate an error. */
     if( onoff ) sqlite3_str_appendf(pOut,"UNKNOWN(\"\\%c\")",c);
     zPrompt += 2;
@@ -1080,6 +1091,26 @@ static char *expand_prompt(
   if( i>0 && onoff ){
     sqlite3_str_append(pOut, zPrompt, i);
   }
+
+  /* Expand the \B, if there is one and if this is a continuation prompt */
+  if( idxSpace>=0 && zPrior!=0 && zPrior[0]!=0 ){
+    char *zOther = expand_prompt(p, 0, p->mainPrompt);
+    int nOther = strlen30(zOther);
+    sqlite3_free(zOther);
+    if( nOther>sqlite3_str_length(pOut) ){
+      char *z;
+      int nNew = nOther - sqlite3_str_length(pOut);
+      int len;
+      sqlite3_str_appendchar(pOut, nNew, ' ');
+      len = sqlite3_str_length(pOut);
+      if( len>idxSpace ){
+        z = sqlite3_str_value(pOut);
+        memmove(z+idxSpace+nNew, z+idxSpace, len-nNew-idxSpace);
+        memset(z+idxSpace, ' ', nNew);
+      }
+    }
+  }
+  
   return sqlite3_str_finish(pOut);
 }
 
@@ -12817,8 +12848,8 @@ static void main_init(ShellState *p) {
 #endif
   sqlite3_config(SQLITE_CONFIG_URI, 1);
   sqlite3_config(SQLITE_CONFIG_MULTITHREAD);
-  sqlite3_snprintf(sizeof(p->mainPrompt), p->mainPrompt,"sqlite> ");
-  sqlite3_snprintf(sizeof(p->contPrompt), p->contPrompt,"   ...> ");
+  sqlite3_snprintf(sizeof(p->mainPrompt), p->mainPrompt,"SQLite:\\f> ");
+  sqlite3_snprintf(sizeof(p->contPrompt), p->contPrompt,"\\B...\\H> ");
 }
 
 /*