/**
 * 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 21353 2012-03-14 09:46:51Z jojaba_67 $
 */

// Localization
final static String CharacterAtCaretLabel = jEdit.getProperty("macro.rs.DisplayCharacterCode.CharacterAtCaret.label", "Character at caret:"); 
 
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(CharacterAtCaretLabel + " ");
		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);
