Paste with Indentation

Revision as of 22:09, 26 April 2012 by Ted (Talk | contribs) (Behaviors)

Description

This article describes a new pasting behavior which is smarter than the regular paste-as-it-is behavior in terms of indentation. However the implementation will remain simple without using heavy Eiffel parser to reformat the text being pasted.

Behaviors

In general: Adjust the number of leading tabs for each line in the pasting text by the result of the number of existing tabs before the editor cursor substracting the number of leading tabs in the pasting text.

Except:

  • There is already non-tabulation character before the editor cursor
  • NC = 0
  • NP = 0

Note:

  • Number of tabulations before the cursor (NC)
  • Number of leading tabulations of the text being pasted (NP)

Behavior 1: Multiple lines with leading tabs in pasting text

Copied text:

Behavior 1 copied text.PNG

Behavior 1.1

Pasted at:

Behavior 1 1 pasted at.PNG

Result:

Behavior 1 1 result.PNG

Summury:

  • Remove tabs before the cursor.
  • The text pasted is indented by one tabulation (NC - NP)

Behavior 1.2

Pasted at:

Behavior 1 2 pasted at.PNG

Result:

Behavior 1 2 result.PNG

Summury:

  • Remove tabs before the cursor.
  • The text pasted is not modified when (NC - NP) = 0

Behavior 1.3

Pasted at:

Behavior 1 3 pasted at.PNG

Result:

Behavior 1 3 result.PNG

Summury:

  • Nothing has been done to the pasted text when NC = 0

Behavior 2: Multiple lines with no tab in pasting text

Copied text:

Behavior 2 copied text.PNG

Behavior 2.1

Pasted at:

Behavior 2 1 pasted at.PNG

Result:

Behavior 2 1 result.PNG

Summury:

  • Nothing has been done to the pasted text when NP = 0

Behavior 2.2

Pasted at:

Behavior 2 2 pasted at.PNG

Result:

Behavior 2 2 result.PNG

Summury:

  • Nothing has been done to the pasted text when NP = 0

Behavior 3: Single line with leading tabs in pasting text

Copied text:

Behavior 3 copied text.PNG

Behavior 3.1

Pasted at:

Behavior 3 1 pasted at.PNG

Result:

Behavior 3 1 result.PNG

Summury:

  • Remove tabs before the cursor.
  • The text pasted is indented by one tabulation (NC - NP)

Behavior 3.2

Pasted at:

Behavior 3 2 pasted at.PNG

Result:

Behavior 3 2 result.PNG

Summury:

  • Remove tabs before the cursor.
  • The text pasted is not modified when (NC - NP) = 0

Behavior 3.3

Pasted at:

Behavior 3 3 pasted at.PNG

Result:

Behavior 3 3 result.PNG

Summury:

  • Nothing is done to the text pasted when NC = 0

Behavior 4

Copied text:

Behavior 4 copied text.PNG

Behavior 4.1

Pasted at:

Behavior 4 1 pasted at.PNG

Result:

Behavior 4 1 result.PNG

Summury:

  • Remove tabs before the cursor.
  • The text pasted is indented by one tabulation (NC - NP)
  • This is a good example to show this pasting behavior's advantage. Paste-as-it-is requires 4 steps to get this result.