MorphyMac / roottools

Automatically exported from code.google.com/p/roottools
0 stars 0 forks source link

Read response char per char #25

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi,

I want to use a program in the shell which generates percentage advancement.
For that the shell program use the char(8) which corresponds to Backspace.

I also want to refresh a view in the application each time the percentage is 
refreshed.

For now, I use that:
 Process localProcess = Runtime.getRuntime().exec(theCommandToExecute);
            BufferedReader localBufferedReader = new BufferedReader(new InputStreamReader(localProcess.getInputStream()));

 while ((mCharToCheck = (char) localBufferedReader.read()) != -1 && !isCancelled) {
                // out of Unicode
                if (mCharToCheck == 65535) {
                    mCommandResult.append("\nEND OF EXECUTION");
                    break;
                }
                //Backspace
                if (mCharToCheck == 8) {
                    mCommandResult.setLength(mCommandResult.length() - 1);
                } else {
                    mCommandResult.append((char) mCharToCheck);
                    publishProgress(CODE_UPDATE_AVAILABLE, mCommandResult.toString());
                }
            }

I am sure your library is more stable that my little code, but unfortunately I 
notice that the listener Result is refreshed line per line (as per the source 
code of the Class Worker).

Is there a way to get the result character per character?

Original issue reported on code.google.com by mich...@benesty.fr on 8 Nov 2012 at 10:06

GoogleCodeExporter commented 8 years ago

I think this request is outside the scope of what RootTools is intended to 
do/provide and at this time will not be implemented in RootTools but it is 
something that I may look into for a future release down the road.

If you want to provide a patch to RootTools Shell.java that will allow for this 
then I will take that under consideration as well. 

Original comment by Stericso...@gmail.com on 29 Jan 2013 at 9:51