Logo Search packages:      
Sourcecode: jline version File versions  Download package

final void jline::ConsoleReader::setBuffer ( final String  buffer  )  throws IOException [inline, private]

Set the current buffer's content to the specified String. The visual console will be modified to show the current buffer.

buffer the new contents of the buffer.

Definition at line 957 of file ConsoleReader.java.

References backspace(), killLine(), and putString().

Referenced by moveHistory().

            // don't bother modifying it if it is unchanged
            if (buffer.equals (buf.buffer.toString ()))

            // obtain the difference between the current buffer and the new one
            int sameIndex = 0;
            for (int i = 0, l1 = buffer.length (), l2 = buf.buffer.length ();
                  i < l1 && i < l2; i++)
                  if (buffer.charAt (i) == buf.buffer.charAt (i))

            int diff = buf.buffer.length () - sameIndex;

            backspace (diff); // go back for the differences
            killLine (); // clear to the end of the line
            buf.buffer.setLength (sameIndex); // the new length
            putString (buffer.substring (sameIndex)); // append the differences

Generated by  Doxygen 1.6.0   Back to index