Building a fully functional code editor based on the JFace Text framework: Part 5th

Source: Internet
Author: User

Text Decoration

Text Decoration

Text decoration is a necessary feature for the Code Editor. Let's take a look at the application of text decoration in the Java editor:

Figure 1. Text decorations in the Java editor

You can see that the Java editor marks the wrong part with a wavy red line, and you can see that for the template, there is a small rectangle around the template parameter, and a corresponding error icon appears on the left. These are called text decorations.

Tip: Templates will be introduced in future articles

When we edit the code, error is unavoidable, so with the text decoration function, we can quickly find the wrong location, which is very useful for code editing. Here's a look at the concepts you need to know to implement the text decoration feature.

Annotation

The term Annotation has been used very well, and is seen in many places, such as the concept of Annotation in J2SE 5.0. In the case of JTF, annotations refer to specific information that is bound to a block of text area, and can be customized for specific information. You can look at the Annotation class in JTF, see it has type information, have additional textual information, and it has many subclasses, and subclasses also contain some extended information.

It is important to note that the annotation contains the type information, through the type, you can know the purpose and function of a callout, and then it can be reflected in the interface. The red wavy line in Figure 1 is actually a callout with the wrong type in that position.

Ruler

A Ruler (ruler) is an area that displays auxiliary information, which is generally attached to the surrounding editor. For example, the two icons in Figure 1 that represent errors are displayed on the Verticalruler (vertical ruler). There can be more than one ruler, and in Figure 1 you can see another ruler that shows the line number, and how many rulers are required to customize it.

Iannotationpresentation

The name inside with "presentation" the words are related to the interface rendering, and iannotationpresentation is used to render the annotation. This interface is only responsible for drawing the callout on the ruler, and the icon in Figure 1 that represents the error is from here. If your own defined annotation does not implement this interface, then it will not appear on the ruler.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.