/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
- /**
- * Display int and hex values for the character at
- * the caret in the status bar.
- *
- * Copyright 2004 Ollie Rutherfurd <oliver@jedit.org>
- *
- * $Id: Display_Character_Code.bsh 5050 2004-05-24 19:24:56Z orutherfurd $
- */
- void displayCharacterCode(View view)
- {
- JEditTextArea textArea = view.getTextArea();
- int caret = textArea.getCaretPosition();
- int line = textArea.getCaretLine();
- if(caret < textArea.getLineEndOffset(line)-1)
- {
- char c = buffer.getText(caret,1).charAt(0);
- StringBuffer buf = new StringBuffer();
- buf.append("Character at caret: ");
- buf.append("int=").append((int)c).append(", ");
- buf.append("hex=").append(Integer.toString((int)c,16));
- view.getStatus().setMessageAndClear(buf.toString());
- }
- else
- Toolkit.getDefaultToolkit().beep();
- }
- displayCharacterCode(view);