Indexing and tagging
Though we managed to leverage some built-in functionality to gain a quick advantage, we need more control over the text area so that we can bend it to our will. This will require the ability to target each character or location of the text with precision.
We will need to know the exact position of each character, the cursor, or the selected area in order to do anything with the contents of the editor.
The Text widget offers us the ability to manipulate its content using index
, tags
, and mark
, which let us target a position or place within the text area for manipulation.
Index
Indexing helps you target a particular place within a piece of text. For example, if you want to mark a particular word in bold, red, or in a different font size, you can do so if you know the index of the starting point and the index of the end point that needs to be targeted.
The index must be specified in one of the following formats:
The index format |
Description |
---|---|
|
This refers to the character... |