void setStyle(Widget widget) {
	Point sel = text.getSelectionRange();
	if ((sel == null) || (sel.y == 0)) return;
	StyleRange style;
	for (int i = sel.x; i<sel.x+sel.y; i++) {
		StyleRange range = text.getStyleRangeAtOffset(i);
		if (range != null) {
			style = (StyleRange)range.clone();
			style.start = i;
			style.length = 1;
		} else {
			style = new StyleRange(i, 1, null, null, SWT.NORMAL);
		}
		if (widget == boldButton) {
			style.fontStyle ^= SWT.BOLD;
		} else if (widget == italicButton) {
			style.fontStyle ^= SWT.ITALIC;						
		} else if (widget == underlineButton) {
			style.underline = !style.underline;
		} else if (widget == strikeoutButton) {
			style.strikeout = !style.strikeout;
		}
		text.setStyleRange(style);
	}
	text.setSelectionRange(sel.x + sel.y, 0);			
}