PageRenderTime 61ms CodeModel.GetById 30ms RepoModel.GetById 0ms app.codeStats 0ms

/jEdit/tags/jedit-4-3-pre5/macros/Misc/Display_Character_Code.bsh

#
Unknown | 28 lines | 26 code | 2 blank | 0 comment | 0 complexity | c6052a3b8ea9d83b9510b14c38f3dacb MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
  1. /**
  2. * Display int and hex values for the character at
  3. * the caret in the status bar.
  4. *
  5. * Copyright 2004 Ollie Rutherfurd <oliver@jedit.org>
  6. *
  7. * $Id: Display_Character_Code.bsh 5050 2004-05-24 19:24:56Z orutherfurd $
  8. */
  9. void displayCharacterCode(View view)
  10. {
  11. JEditTextArea textArea = view.getTextArea();
  12. int caret = textArea.getCaretPosition();
  13. int line = textArea.getCaretLine();
  14. if(caret < textArea.getLineEndOffset(line)-1)
  15. {
  16. char c = buffer.getText(caret,1).charAt(0);
  17. StringBuffer buf = new StringBuffer();
  18. buf.append("Character at caret: ");
  19. buf.append("int=").append((int)c).append(", ");
  20. buf.append("hex=").append(Integer.toString((int)c,16));
  21. view.getStatus().setMessageAndClear(buf.toString());
  22. }
  23. else
  24. Toolkit.getDefaultToolkit().beep();
  25. }
  26. displayCharacterCode(view);