-C A\sprototype\sof\scode\sthat\sshows\show\sto\sexpand\sbackslash\sescapes\sin\sthe\nCLI\sprompt.
-D 2026-04-09T23:37:48.087
+C Improvements\sto\sthe\sway\s\x\sworks\sso\sthat\sit\scan\sbe\sused\sto\schange\nthe\sprompt\scolor.\s\sThis\sreally\smesses\swith\slinenoise,\sthough.
+D 2026-04-10T00:55:40.521
F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F src/resolve.c 928ff887f2a7c64275182060d94d06fdddbe32226c569781cf7e7edc6f58d7fd
F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97
F src/select.c ffe199f025a0dd74670d2a77232bdea364a4d7b36f32c64a6572d39ba6a11576
-F src/shell.c.in 35f99690f368ef171713cbccd89efef382944e4b85396bdb78e6995636e278b3
+F src/shell.c.in 2bbbb04153354fe3d11677d69ce7b6d5bfe8113e2d3693791915590eaa4f1bce
F src/sqlite.h.in e2915e4a86d5e0783afb5cb72411df38d987c7f3c5aa2d5441b8e74d30b649d8
F src/sqlite3.rc 015537e6ac1eec6c7050e17b616c2ffe6f70fca241835a84a4f0d5937383c479
F src/sqlite3ext.h 1b7a0ee438bb5c2896d0609c537e917d8057b3340f6ad004d2de44f03e3d3cca
F tool/warnings.sh a554d13f6e5cf3760f041b87939e3d616ec6961859c3245e8ef701d1eafc2ca2
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
F tool/winmain.c 00c8fb88e365c9017db14c73d3c78af62194d9644feaf60e220ab0f411f3604c
-P 39f6c5a8a7d91e03f89b13496e333b9500977a2cbcc0c27ba14dfb87dc81e678
-R d2a4bc02232fb4db2f52e0b9d98461ba
+P 9cf28959671920b4909521bb1db6f0cbbc85448fbf3594c43b4000505b4e055b
+R 1af695b623ae09a49f6867ddfb6fa639
U drh
-Z f5b6fe9da177b5e89ebf6c4cb7c9f5ea
+Z 856f286521a626031b862b8cbac557c5
# Remove this line to create a well-formed Fossil manifest.
sqlite3_str *pOut = sqlite3_str_new(0);
int i;
char c;
+ int onoff = 1;
for(i=0; zPrompt[i]; i++){
if( zPrompt[i]!='\\' ) continue;
if( i>0 ){
- sqlite3_str_append(pOut, zPrompt, i);
+ if( onoff ) sqlite3_str_append(pOut, zPrompt, i);
zPrompt += i;
i = 0;
}
while( i<=2 && zPrompt[i+1]>='0' && zPrompt[i+1]<='7' ){
v = v*8 + zPrompt[++i] - '0';
}
- sqlite3_str_appendchar(pOut, 1, v);
+ if( onoff ) sqlite3_str_appendchar(pOut, 1, v);
zPrompt += i+1;
i = -1;
continue;
}
+ if( c=='e' ){
+ /* \e is \033 "Escape" */
+ if( onoff ) sqlite3_str_append(pOut, "\033", 1);
+ zPrompt += 2;
+ i = -1;
+ continue;
+ }
+
+ /* The intent of the following codes it to provide alternative
+ ** text displays depending on whether or not the connection is
+ ** currently in a transaction. Example 1: Show a "*" before the ">"
+ ** like psql:
+ **
+ ** .prompt 'sqlite\x*\;> '
+ **
+ ** Example 2: Show database filename is blue if not in a transaction,
+ ** or red if within a transaction:
+ **
+ ** .prompt '\e[1;\x31\:34\;m\f>\e[0m '
+ */
+ if( c==':' ){
+ /* toggle display on/off */
+ onoff = !onoff;
+ zPrompt += 2;
+ i = -1;
+ continue;
+ }
+ if( c==';' ){
+ /* Turn display on */
+ onoff = 1;
+ zPrompt += 2;
+ i = -1;
+ continue;
+ }
if( c=='x' ){
- /* \x becomes "*" if in a transaction and nothing if not */
- if( p->db && !sqlite3_get_autocommit(p->db) ){
- sqlite3_str_append(pOut, "*", 1);
- }
+ /* \x turns display off not in a transaction, on if in txn */
+ onoff = p->db && !sqlite3_get_autocommit(p->db);
zPrompt += 2;
i = -1;
continue;
}
+
if( c=='f' || c=='F' || c=='~' ){
/* \f becomes the tail of the database filename */
/* \F becomes the full pathname */
/* \~ becomes the full pathname relative to $HOME */
- sqlite3_filename pFN = p->db ? sqlite3_db_filename(p->db,0) : 0;
- const char *zFN;
- if( pFN && (zFN = sqlite3_filename_database(pFN))!=0 ){
- if( c=='f' ){
- const char *zTail = strrchr(zFN,'/');
- if( zTail && zTail[1] ) zFN = &zTail[1];
- }else if( c=='~' ){
- const char *zHOME = getenv("HOME");
- size_t nHOME = zHOME ? strlen(zHOME) : 0;
- if( nHOME<strlen(zFN) && memcmp(zHOME,zFN,nHOME)==0 ){
- sqlite3_str_append(pOut,"~",1);
- zFN += nHOME;
+ if( onoff ){
+ sqlite3_filename pFN = p->db ? sqlite3_db_filename(p->db,0) : 0;
+ const char *zFN = pFN ? sqlite3_filename_database(pFN) : ":memory:";
+ if( zFN ){
+ if( c=='f' ){
+ const char *zTail = strrchr(zFN,'/');
+ if( zTail && zTail[1] ) zFN = &zTail[1];
+ }else if( c=='~' ){
+ const char *zHOME = getenv("HOME");
+ size_t nHOME = zHOME ? strlen(zHOME) : 0;
+ if( nHOME<strlen(zFN) && memcmp(zHOME,zFN,nHOME)==0 ){
+ sqlite3_str_append(pOut,"~",1);
+ zFN += nHOME;
+ }
}
+ sqlite3_str_appendall(pOut, zFN);
}
- sqlite3_str_appendall(pOut, zFN);
}
zPrompt += 2;
i = -1;
}
/* No match to a known escape. Generate an error. */
- sqlite3_str_appendf(pOut,"UNKNOWN(\"\\%c\")",c);
+ if( onoff ) sqlite3_str_appendf(pOut,"UNKNOWN(\"\\%c\")",c);
zPrompt += 2;
i = -1;
}
- if( i>0 ){
+ if( i>0 && onoff ){
sqlite3_str_append(pOut, zPrompt, i);
}
return sqlite3_str_finish(pOut);