From: drh Date: Thu, 6 Jul 2017 20:08:17 +0000 (+0000) Subject: Tab-completion now also works using readline/editline. X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=48d046261adcac393b15508216faf1821cad73f4;p=thirdparty%2Fsqlite.git Tab-completion now also works using readline/editline. FossilOrigin-Name: c906739f0c1046b57a8c6d4aa32dbfbb4c59a8d94eb87243bf5135c665492129 --- diff --git a/manifest b/manifest index af2574b781..106cd47932 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Use\sthe\ssqlite3_namelist()\sinterface\sto\simplement\ssimple\stab-completion\susing\nlinenoise. -D 2017-07-06T19:26:23.558 +C Tab-completion\snow\salso\sworks\susing\sreadline/editline. +D 2017-07-06T20:08:17.868 F Makefile.in 081e48dfe7f995d57ce1a88ddf4d2917b4349158648a6cd45b42beae30de3a12 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 4ebb1d257cac7fb1bcb4ba59278416d410ff1c4bf59447a9c37a415f3516056a @@ -449,7 +449,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c d1e69759e7a79c156c692793f5d16f82f9a60ce5e82efd95e4374b2423034946 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c c9f7b7196e196e93979665680d055a789938b8e025556097bf484b184c0dd576 -F src/shell.c 5f5dc595336874ebbb9a80f90d977665268e2b8daaaeaa3e4e76455e4234e82a +F src/shell.c 5a93d49fca032b7940ddda558aebe64dda20918677602f2005cfd4ca20f66a6d F src/sqlite.h.in 51170f66b6fe5ab8d74caf40a790ea738c34ec0ffc58fca49e00ecf3b070976c F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 58fd0676d3111d02e62e5a35992a7d3da5d3f88753acc174f2d37b774fbbdd28 @@ -1628,7 +1628,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 702911104424f03f6ebe3beb9090f73b52abe2e655537b8cd8a32e799718ed14 -R 136b08bfcc403c1ab529d5b433d85a10 +P 5cc7b0e2ca87220d714f3994a206ca903f5b82daa920fd625de035c646447800 +R e9426d4e3241285f34824e77961fa8c8 U drh -Z 6a3ca52fda5279d8cf1bff9e360e9d61 +Z 5ec79e3f339c2091ba1a4808013649e6 diff --git a/manifest.uuid b/manifest.uuid index 651ec5b320..fe5334f636 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5cc7b0e2ca87220d714f3994a206ca903f5b82daa920fd625de035c646447800 \ No newline at end of file +c906739f0c1046b57a8c6d4aa32dbfbb4c59a8d94eb87243bf5135c665492129 \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index 49b6649bf0..d6738eca45 100644 --- a/src/shell.c +++ b/src/shell.c @@ -3599,7 +3599,34 @@ static void open_db(ShellState *p, int keepAlive){ } } -#ifdef HAVE_LINENOISE +#if HAVE_READLINE || HAVE_EDITLINE +/* +** Readline completion callbacks +*/ +static char *readline_completion_generator(const char *text, int state){ + static char **azCompletions = 0; + static int iCompletion = 0; + char *zRet; + if( state==0 ){ + sqlite3_free(azCompletions); + azCompletions = sqlite3_namelist(globalDb, text, -1, 0); + iCompletion = 0; + } + zRet = azCompletions[iCompletion++]; + if( zRet==0 ){ + sqlite3_free(azCompletions); + azCompletions = 0; + }else{ + zRet = strdup(zRet); + } + return zRet; +} +static char **readline_completion(const char *zText, int iStart, int iEnd){ + rl_attempted_completion_over = 1; + return rl_completion_matches(zText, readline_completion_generator); +} + +#elif HAVE_LINENOISE /* ** Linenoise completion callback */ @@ -7665,7 +7692,9 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){ } } if( zHistory ){ shell_read_history(zHistory); } -#ifdef HAVE_LINENOISE +#if HAVE_READLINE || HAVE_EDITLINE + rl_attempted_completion_function = readline_completion; +#elif HAVE_LINENOISE linenoiseSetCompletionCallback(linenoise_completion); #endif rc = process_input(&data, 0);