Hi All, I tried creating an incremental search function, but found that the screen didn't update until you returned. So, all the interpretting of keys and searching to the next match took place "in the dark". You didn't know where the match was until you finally exited my incremental search function. I dug through the C code, and found a "tui.draw()" function, and tried to export it, just to see if I could force a screen update before returning. But, that didn't work (I couldn't give you specifics on which function I exported, unfortunately, that code is at work). Has anyone found a some way to force an update of the screen inside of user-code? Lee P.S. My incremental search: sub lp.incrementalSearch( doc ) { local dummyFlags; local done = 0; local textToSearchFor = ""; while( !done ) { local retVal; /* This is a hacked-up version of Angel's tui.readline that reads only ONE character, then returns it... */ retVal = lp.readlineIncremental( "Incremental search: ", textToSearchFor ); if( retVal[ 1 ] eq 'ctrl-s' ) { mp.search( doc, textToSearchFor ); } else /* see if it is another non-alphanum keystroke (a key name) */ if( size( retVal[ 1 ] ) > 1 ) { done = 1; } else { /* "0" is the string, "1" is the last key */ textToSearchFor = retVal[ 0 ]; mp.search( doc, textToSearchFor ); } if( !done ) { /* highlight snippet so it is visible */ mp.unmark( doc ); origCursor = doc.txt.x; doc.txt.x -= size( textToSearchFor ); mp.mark( doc ); doc.txt.x = origCursor; mp.mark( doc ); doc.txt.mod++; mp.tui.draw( doc ); } } } /* This is Angel's tui.readline(), but with the "while(1)" removed so that we can fetch one character at a time, but also returns the whole string */ sub lp.readlineIncremental(prompt, default ) /* the readline function, with special functionality in 'flags' */ { local c, r, h, i, v, lastKey; mp.tui.prompt(prompt ~ ' '); c = mp.tui.getxy(); r = default || ''; /* create the clipping regular expression */ v = '/.{1,' ~ (mp.window.tx - c[0] - 1) ~ '}$/'; i = 0; { local k, s; /* builds the string */ s = regex(v, r) || ''; /* draws the string */ mp.tui.move(c[0], c[1], 1); mp.tui.addstr(s); k = mp.tui.getkey(); lastKey = k; if(k eq 'enter') break; else if(k eq 'escape') { r = NULL; break; } else if(k eq 'backspace') r = sregex('/.$/', r); else if(k eq 'ctrl-u') r = ''; else if(k eq 'space') r = r ~ ' '; else if(k eq 'cursor-up' && size(h)) { i--; r = h[i % size(h)]; } else if(k eq 'cursor-down' && size(h)) { i++; r = h[i % size(h)]; } else if(size(k) == 1) r = r ~ k; } return( [ r, lastKey ] ); } -- To unsubscribe, send mail to mp-unsubscribe_lists.triptico.com.Received on Sun Sep 09 2007 - 17:57:54 CEST
This archive was generated by hypermail 2.2.0 : Thu Apr 10 2008 - 08:59:26 CEST