PageRenderTime 132ms CodeModel.GetById 128ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 1ms

/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
 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);