PageRenderTime 23ms CodeModel.GetById 14ms app.highlight 8ms 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
10void displayCharacterCode(View view)
11{
12	JEditTextArea textArea = view.getTextArea();
13	int caret = textArea.getCaretPosition();
14	int line = textArea.getCaretLine();
15	if(caret < textArea.getLineEndOffset(line)-1)
16	{
17		char c = buffer.getText(caret,1).charAt(0);
18		StringBuffer buf = new StringBuffer();
19		buf.append("Character at caret: ");
20		buf.append("int=").append((int)c).append(", ");
21		buf.append("hex=").append(Integer.toString((int)c,16));
22		view.getStatus().setMessageAndClear(buf.toString());
23	}
24	else
25		Toolkit.getDefaultToolkit().beep();
26}
27
28displayCharacterCode(view);