File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1381,7 +1381,10 @@ nhl_pushkey(lua_State *L)
13811381 if (argc == 1 ) {
13821382 const char * key = luaL_checkstring (L , 1 );
13831383
1384- cmdq_add_key (CQ_CANNED , key [0 ]);
1384+ while (* key ) {
1385+ cmdq_add_key (CQ_CANNED , * key );
1386+ key ++ ;
1387+ }
13851388 }
13861389
13871390 return 0 ;
Original file line number Diff line number Diff line change @@ -1867,6 +1867,27 @@ void
18671867getlin (const char * query , char * bufp )
18681868{
18691869 boolean old_bot_disabled = gb .bot_disabled ;
1870+ char * obufp = bufp ;
1871+ boolean got_cmdq = FALSE;
1872+ struct _cmd_queue * cmdq = NULL ;
1873+
1874+ while ((cmdq = cmdq_pop ()) != 0 ) {
1875+ if (cmdq -> typ == CMDQ_KEY ) {
1876+ got_cmdq = TRUE;
1877+ * bufp = (cmdq -> key != '\n' ) ? cmdq -> key : '\0' ;
1878+ bufp ++ ;
1879+ if (cmdq -> key == '\n' )
1880+ break ;
1881+ } else {
1882+ break ;
1883+ }
1884+ }
1885+
1886+ if (got_cmdq ) {
1887+ * bufp = '\0' ;
1888+ pline ("%s %s" , query , obufp );
1889+ return ;
1890+ }
18701891
18711892 program_state .in_getlin = 1 ;
18721893 gb .bot_disabled = TRUE;
Original file line number Diff line number Diff line change @@ -121,3 +121,13 @@ for func, fval in pairs(tests) do
121121 end
122122 end
123123end
124+
125+ function test_getlin ()
126+ nh .pushkey (" AbC" );
127+ local str = nh .getlin (" What?" );
128+ if str ~= " AbC" then
129+ error (" nh.getlin fail, got \" " .. str .. " \" " );
130+ end
131+ end
132+
133+ test_getlin ();
You can’t perform that action at this time.
0 commit comments