history[currentHistoryLine] = inputLine; currentHistoryLine++;
AppendHistoryLine(inputLine);
  protected void processKeyEvent(KeyEvent e)  {    inputDirty = true;    if ((e.getModifiers() & InputEvent.CTRL_MASK) == InputEvent.CTRL_MASK)    {      if (KeyEvent.KEY_PRESSED != e.getID())        return;      if (e.getKeyCode() == (int)'C')      {        //out.println("Copy");        setClipboardContents( gatheredMultiLine+inputLine );      }      else if (e.getKeyCode() == (int)'V')      {        try        {          String toInsert = getClipboardContents();          if (toInsert != null)          {            int cr = toInsert.indexOf('\n');            while (cr >= 0)            {              inputLine = inputLine+toInsert.substring(0,cr);              toInsert = toInsert.substring(cr+1,toInsert.length());              cr = toInsert.indexOf('\n');//System.out.println("");              history[currentHistoryLine] = inputLine;              currentHistoryLine++;              AddLinesStatic(48,inputPrompt,inputLine);              if (inputLine.charAt(inputLine.length()-1) == '\\')                gatheredMultiLine = gatheredMultiLine + inputLine.substring(0,inputLine.length()-1);              else                PerformRequest("Out> ",gatheredMultiLine+inputLine);              ResetInput();            }            inputLine = inputLine+toInsert;            RefreshHintWindow();            repaint();            return;          }          //  out.println("Paste");//          out.println(toInsert);        }        catch (Exception ex)        {        }      }      else      {        return;      }    }    if (KeyEvent.KEY_PRESSED == e.getID())        {      if (e.VK_SHIFT == e.getKeyCode()) {return;}      if (e.VK_CONTROL == e.getKeyCode()) {return;}      if (e.VK_ALT == e.getKeyCode()) {return;}      else if (e.VK_HOME == e.getKeyCode())      {        cursorPos = 0;        }/*Does not seem to work?      else if (e.VK_COPY == e.getKeyCode())      {        System.out.println("COPY");      }      else if (e.VK_PASTE == e.getKeyCode())      {        System.out.println("PASTE");      }*/      else if (e.VK_END == e.getKeyCode())      {        cursorPos = inputLine.length();        }      else if (e.VK_LEFT == e.getKeyCode())      {        if (cursorPos>0)         {          cursorPos--;            RefreshHintWindow();          repaint();          return;        }      }      else if (e.VK_BACK_SPACE == e.getKeyCode())      {        if (cursorPos>0)         {          cursorPos--;            inputLine = new StringBuffer(inputLine).delete(cursorPos,cursorPos+1).toString();          RefreshHintWindow();          repaint();          return;        }      }      else if (e.VK_ESCAPE == e.getKeyCode())      {        if (hintWindow != null)        {          hintWindow = null;        }        else        {          ResetInput();        }        repaint();        return;      }      else if (e.VK_UP == e.getKeyCode())      {        {          String prefix = inputLine.substring(0,cursorPos);          int i = historyBrowse - 1;          while (i > 0)          {            if (history[i].startsWith(prefix))              break;            i--;          }          if (i >= 0 && i != historyBrowse && history[i].startsWith(prefix))          {            historyBrowse = i;            inputLine = history[historyBrowse];          }        }      }      else if (e.VK_DOWN == e.getKeyCode())      {        {          String prefix = inputLine.substring(0,cursorPos);          int i = historyBrowse + 1;          while (i < currentHistoryLine)          {            if (history[i].startsWith(prefix))              break;            i++;          }          if (i < currentHistoryLine && history[i].startsWith(prefix))          {            historyBrowse = i;            inputLine = history[historyBrowse];          }          else           {            int pos = cursorPos;            ResetInput();            inputLine = prefix;            cursorPos = pos;          }        }      }      else if (e.VK_RIGHT == e.getKeyCode())      {        if (cursorPos<inputLine.length())         {          cursorPos++;            RefreshHintWindow();          repaint();          return;        }      }      else if (e.VK_ENTER == e.getKeyCode())      {        history[currentHistoryLine] = inputLine;        currentHistoryLine++;        AddLinesStatic(48,inputPrompt,inputLine);        if (inputLine.charAt(inputLine.length()-1) == '\\')          gatheredMultiLine = gatheredMultiLine + inputLine.substring(0,inputLine.length()-1);        else          PerformRequest("Out> ",gatheredMultiLine+inputLine);        ResetInput();        RefreshHintWindow();        repaint(0);      }      else      {        int c = (int)e.getKeyChar();        if (c>=32 && c < 128)        {          inputLine = new StringBuffer(inputLine).insert(cursorPos,e.getKeyChar()).toString();          cursorPos++;          RefreshHintWindow();        }      }      inputDirty=true;      repaint();//0,getHeight()-2*fontHeight,getWidth(),2*fontHeight);    }  }