use of ch.cyberduck.binding.foundation.NSRange in project cyberduck by iterate-ch.
the class HyperlinkAttributedStringFactory method create.
/**
* @param value Existing attributes
* @param hyperlink URL
* @return Clickable and underlined string to put into text field.
*/
private static NSAttributedString create(final NSMutableAttributedString value, final String hyperlink) {
final NSRange range = NSRange.NSMakeRange(new NSUInteger(0), value.length());
value.beginEditing();
value.addAttributeInRange(NSMutableAttributedString.LinkAttributeName, hyperlink, range);
// make the text appear in blue
value.addAttributeInRange(NSMutableAttributedString.ForegroundColorAttributeName, NSColor.blueColor(), range);
// system font
value.addAttributeInRange(NSMutableAttributedString.FontAttributeName, NSFont.systemFontOfSize(NSFont.smallSystemFontSize()), range);
// next make the text appear with an underline
value.addAttributeInRange(NSMutableAttributedString.UnderlineStyleAttributeName, NSNumber.numberWithInt(NSMutableAttributedString.SingleUnderlineStyle), range);
value.endEditing();
return value;
}
use of ch.cyberduck.binding.foundation.NSRange in project cyberduck by iterate-ch.
the class PreferencesController method mark.
private void mark(NSMutableAttributedString text, PatternSyntaxException e) {
if (null == e) {
text.removeAttributeInRange(NSAttributedString.ForegroundColorAttributeName, NSRange.NSMakeRange(new NSUInteger(0), text.length()));
return;
}
// The approximate index in the pattern of the error
int index = e.getIndex();
NSRange range = null;
if (-1 == index) {
range = NSRange.NSMakeRange(new NSUInteger(0), text.length());
}
if (index < text.length().intValue()) {
// Initializes the NSRange with the range elements of location and length;
range = NSRange.NSMakeRange(new NSUInteger(index), new NSUInteger(1));
}
text.addAttributesInRange(RED_FONT, range);
}
Aggregations