# TSynCompletionProposal

1. Introduction
2. Painting and Formatting

## Introduction

## Painting and Formatting

### I. Introduction

> In this section I want to describe the new format mechanism, column painting and how existing applications must be modified to work with the new painting method.

### II. Format Commands

> The old binary format commands are exchanged for escape sequences. This was necessary because several Delphi function don't like low ASCII characters in strings. (Especially #0s)

> The new format commands all start with a backslash followed by a command identifier and a parameter. Parameters are enclosed by { and }. This is similar to the syntax of TeX. If you want to use a single backslash without starting a command, just type two backslashes.

> #### Example

> A formatted string like
> `\color{clNavy}\style{+I}\\\\This\style{~I}\color{0} is a\style{+B}\color{$0000FF} Test`
> which was represented fomerly by
> `#1#0#0#128#3'I'\\This'#3'i'#1#0#0#0' is a '#3'B'#1#255#0#0' Test'`
> would produce this output:

> #### All commands

> Command Identifier | Description | Parameter
> color | Changes the font color | Either a Delphi color identifier or a hexadecimal color value. (Pascal style) (In fact anything that the Delphi function StringToColor can parse)
> style | Changes the font style | Either a "+", a "-" or a "~" followed by either "B", "I", "S" or "U" (for bold, italic, strike-out and underline). "+"/"-" switches the style on/off, while "~" toggles the specified font style.
> column | Marks the end of the current column | No parameters for this command.
> image | Inserts an image from the image list provided by the ImageList property | Index of the image you want to insert.
> hspace | Inserts an empty margin. Only useful in combination with the \image{} command. | Width of the margin in pixels.

### III. Column Painting

> I've completly reworked column painting. The old TSynCompletionProposal had some rudimentary implicit column painting functionality. (Which could be controlled by the BiggestWord property)

> The new method supports any number of columns. The \column{} command moves the cursor to the beginning of the next column, just like the old #9-command did. \column{} does no longer toggle the bold font style. As a replacement there is a default font style for every column.

> #### Example

> A formatted string...
> `function \column{}Length(S: string): \column{}Integer;`
> ...with these column definitions: ``
> 1. Column: (BiggestWord = "CONSTRUCTOR", FontStyle = [fsBold])
> 2. Column: (BiggestWord = "VERYLONGDELPHIFUNCTION", FontStyle = [fsItalic, fsUnderline])
> 3. Column: (BiggestWord = "INTEGER", FontStyle = [fsBold, fsItalic])
> ...looks like:

### IV. Converting

> To convert a current application using the new TSynCompletionProposal would require these steps:

> 1. Convert the current format strings to the new ones.
> 2. Create one single column with its BiggestWord-property set to your old BiggestWord property.
> 3. Wherever you expected from a #9 to change the font style you have to insert one \style{} command.