Difference between revisions of "TWSocket.LineEdit"

From Overbyte
Jump to navigation Jump to search
 
Line 12: Line 12:
  
 
== Example ==
 
== Example ==
 
+
<syntaxhighlight lang="delphi">
 
   Socket.LineMode := True;            // Enable LineMode  
 
   Socket.LineMode := True;            // Enable LineMode  
 
   Socket.LineEnd  := chr(10)+chr(13); // The sender has to terminate all  
 
   Socket.LineEnd  := chr(10)+chr(13); // The sender has to terminate all  
Line 18: Line 18:
 
                                       // combination
 
                                       // combination
 
   Socket.LineEdit := True;            // Convert backspaces and tabs
 
   Socket.LineEdit := True;            // Convert backspaces and tabs
 +
</syntaxhighlight>
  
 
When the following input string is received from a client connection (note that <font color="darkblue">'''^H'''</font> represents a backspace character):
 
When the following input string is received from a client connection (note that <font color="darkblue">'''^H'''</font> represents a backspace character):

Latest revision as of 20:31, 1 July 2010

Definition

property LineEdit: Boolean;

Description

LineEdit allows the automatic transliteration of certain control characters into their visual representation. In particular, the BACKSPACE (ASCII #08) and TAB (ASCII #09) characters.

When LineEdit is set to True, any BACKSPACE character encountered in the input buffer will cause the buffer position pointer to move back one character, thus deleting it. Likewise, every TAB character will cause the buffer to be padded with the number of SPACE (ASCII #32) characters needed to reach the next tabular column. A tabular column is typically 8 spaces.

LineEdit is typically used in conjunction with LineMode when the incoming data needs to be displayed to a terminal.

Example

<syntaxhighlight lang="delphi">

 Socket.LineMode := True;            // Enable LineMode 
 Socket.LineEnd  := chr(10)+chr(13); // The sender has to terminate all 
                                     // messages sent with this character 
                                     // combination
 Socket.LineEdit := True;            // Convert backspaces and tabs

</syntaxhighlight>

When the following input string is received from a client connection (note that ^H represents a backspace character):

This is a new^H^H^Htest.

TWSocket will convert it to the following:

This is a test.

When the following input string is received from a client connection (note that ^T represents a tab character):

^TCol1^TCol2^T^TCol3

TWSocket will convert it to the following (the ruler represents the position of the tabular columns):

Tab0    Tab1    Tab2    Tab3    Tab4
|-------+-------+-------+-------+-------|
        Col1    Col2            Col3

Best practices

How to