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

void jline::ConsoleReader::printColumns ( final Collection  stuff  )  throws IOException [inline]

Output the specified Collection in proper columns.

Parameters:
stuff the stuff to print

Definition at line 834 of file ConsoleReader.java.

References getTermwidth(), pad(), printNewline(), and printString().

Referenced by jline::CandidateListCompletionHandler::printCandidates().

      {
            if (stuff == null || stuff.size () == 0)
                  return;

            int width = getTermwidth ();
            int maxwidth = 0;
            for (Iterator i = stuff.iterator (); i.hasNext ();
                  maxwidth = Math.max (maxwidth, i.next ().toString ().length ()));

            StringBuffer line = new StringBuffer ();

            for (Iterator i = stuff.iterator (); i.hasNext (); )
            {
                  String cur = (String)i.next ();

                  if (line.length () + maxwidth > width)
                  {
                        printString (line.toString ().trim ());
                        printNewline ();
                        line.setLength (0);
                  }

                  pad (cur, maxwidth + 3, line);
            }

            if (line.length () > 0)
            {
                  printString (line.toString ().trim ());
                  printNewline ();
                  line.setLength (0);
            }
      }


Generated by  Doxygen 1.6.0   Back to index