@@ -5,21 +5,24 @@ Two-way file comparison for Textadept.
5
5
Install this module by copying it into your * ~ /.textadept/modules/* directory or Textadept's
6
6
* modules/* directory, and then putting the following in your * ~ /.textadept/init.lua* :
7
7
8
- require('file_diff')
8
+ ``` lua
9
+ local file_diff = require (' file_diff' )
10
+ ```
9
11
10
12
## Compiling
11
13
12
14
Releases include binaries, so building this modules should not be necessary. If you want
13
15
to build manually, use CMake. For example:
14
16
15
- cmake -S . -B build_dir
16
- cmake --build build_dir --target diff
17
- cmake --install build_dir
17
+ ``` bash
18
+ cmake -S . -B build_dir
19
+ cmake --build build_dir --target diff
20
+ cmake --install build_dir
21
+ ```
18
22
19
23
## Usage
20
24
21
25
A sample workflow is this:
22
-
23
26
1 . Start comparing two files via the "Compare Files" submenu in the "Tools" menu.
24
27
2 . The caret is initially placed in the file on the left.
25
28
3 . Go to the next change via menu or key binding.
@@ -46,113 +49,107 @@ Ctrl+Alt+, | ^⌘, | None | Goto previous difference
46
49
Ctrl+Alt+< | ^⌘< | None | Merge left
47
50
Ctrl+Alt+> | ^⌘> | None | Merge right
48
51
49
- ## Fields defined by ` file_diff `
50
-
51
52
<a id =" file_diff.INDIC_ADDITION " ></a >
52
- ### ` file_diff.INDIC_ADDITION `
53
+ ## ` file_diff.INDIC_ADDITION `
53
54
54
55
The indicator number for text added within lines.
55
56
56
57
<a id =" file_diff.INDIC_DELETION " ></a >
57
- ### ` file_diff.INDIC_DELETION `
58
+ ## ` file_diff.INDIC_DELETION `
58
59
59
60
The indicator number for text deleted within lines.
60
61
61
62
<a id =" file_diff.MARK_ADDITION " ></a >
62
- ### ` file_diff.MARK_ADDITION `
63
+ ## ` file_diff.MARK_ADDITION `
63
64
64
65
The marker for line additions.
65
66
66
67
<a id =" file_diff.MARK_DELETION " ></a >
67
- ### ` file_diff.MARK_DELETION `
68
+ ## ` file_diff.MARK_DELETION `
68
69
69
70
The marker for line deletions.
70
71
71
72
<a id =" file_diff.MARK_MODIFICATION " ></a >
72
- ### ` file_diff.MARK_MODIFICATION `
73
+ ## ` file_diff.MARK_MODIFICATION `
73
74
74
75
The marker for line modifications.
75
76
76
- <a id =" file_diff.addition_color_name " ></a >
77
- ### ` file_diff.addition_color_name `
78
-
79
- The name of the theme color used to mark additions.
80
- The default value is 'green'. If your theme does not define that color, set this field to
81
- your theme's equivalent.
82
-
83
- <a id =" file_diff.deletion_color_name " ></a >
84
- ### ` file_diff.deletion_color_name `
85
-
86
- The name of the theme color used to mark deletions.
87
- The default value is 'red'. If your theme does not define that color, set this field to your
88
- theme's equivalent.
89
-
90
- <a id =" file_diff.modification_color_name " ></a >
91
- ### ` file_diff.modification_color_name `
92
-
93
- The name of the theme color used to mark modifications.
94
- The default value is 'yellow'. If your theme does not define that color, set this field to
95
- your theme's equivalent.
96
-
97
-
98
- ## Functions defined by ` file_diff `
99
-
100
77
<a id =" _G.diff " ></a >
101
- ### ` _G.diff ` (* text1* , * text2* )
78
+ ## ` _G.diff ` (* text1* , * text2* )
79
+
80
+ Returns a list of the differences between strings.
102
81
103
- Returns a list that represents the differences between strings * text1* and * text2* .
104
82
Each consecutive pair of elements in the returned list represents a "diff". The first element
105
83
is an integer: 0 for a deletion, 1 for an insertion, and 2 for equality. The second element
106
84
is the associated diff text.
107
85
108
86
Parameters:
109
-
110
87
- * text1* : String to compare against.
111
88
- * text2* : String to compare.
112
89
113
90
Usage:
114
91
115
- - `diffs = diff(text1, text2)
92
+ ``` lua
93
+ diffs = diff (text1 , text2 )
116
94
for i = 1 , # diffs , 2 do print (diffs [i ], diffs [i + 1 ]) end
117
- `
95
+ ```
96
+
97
+ <a id =" file_diff.addition_color_name " ></a >
98
+ ## ` file_diff.addition_color_name `
99
+
100
+ The name of the theme color used to mark additions.
101
+
102
+ The default value is 'green'. If your theme does not define that color, set this field to
103
+ your theme's equivalent.
104
+
105
+ <a id =" file_diff.deletion_color_name " ></a >
106
+ ## ` file_diff.deletion_color_name `
118
107
119
- Return:
108
+ The name of the theme color used to mark deletions.
120
109
121
- - list of differences
110
+ The default value is 'red'. If your theme does not define that color, set this field to your
111
+ theme's equivalent.
122
112
123
113
<a id =" file_diff.goto_change " ></a >
124
- ### ` file_diff.goto_change ` (* next* )
114
+ ## ` file_diff.goto_change ` ([ * next* =false] )
115
+
116
+ Jumps to the next or previous difference between the two files.
125
117
126
- Jumps to the next or previous difference between the two files depending on boolean * next* .
127
118
[ ` file_diff.start() ` ] ( #file_diff.start ) must have been called previously.
128
119
129
120
Parameters:
130
-
131
- - * next * : Whether to go to the next or previous difference relative to the current line .
121
+ - * next * : Go to the next previous difference relative to the current line,
122
+ as opposed to the previous one .
132
123
133
124
<a id =" file_diff.merge " ></a >
134
- ### ` file_diff.merge ` (* left* )
125
+ ## ` file_diff.merge ` ([ * left* =false ] )
135
126
136
127
Merges a change from one buffer to another, depending on the change under the caret and the
137
128
merge direction.
138
129
139
130
Parameters:
131
+ - * left* : Merge from right to left as opposed to left to right.
140
132
141
- - * left* : Whether to merge from right to left or left to right.
133
+ <a id =" file_diff.modification_color_name " ></a >
134
+ ## ` file_diff.modification_color_name `
135
+
136
+ The name of the theme color used to mark modifications.
137
+
138
+ The default value is 'yellow'. If your theme does not define that color, set this field to
139
+ your theme's equivalent.
142
140
143
141
<a id =" file_diff.start " ></a >
144
- ### ` file_diff.start ` (* file1* , * file2* , * horizontal* )
142
+ ## ` file_diff.start ` ([ * file1* [ , * file2* [ , * horizontal* =false ]]] )
145
143
146
- Highlight differences between files * file1 * and * file2 * , or the user-selected files .
144
+ Highlight differences between files.
147
145
148
146
Parameters:
147
+ - * file1* : String older filename. If ` - ` , uses the current buffer. If ` nil ` , the user
148
+ is prompted for a file.
149
+ - * file2* : String newer filename. If ` - ` , uses the current buffer. If ` nil ` , the user
150
+ is prompted for a file.
151
+ - * horizontal* : Split the view horizontally instead of vertically. The
152
+ default is to compare files side-by-side.
149
153
150
- - * file1* : Optional name of the older file. If ` - ` , uses the current buffer. If ` nil ` ,
151
- the user is prompted for a file.
152
- - * file2* : Optional name of the newer file. If ` - ` , uses the current buffer. If ` nil ` ,
153
- the user is prompted for a file.
154
- - * horizontal* : Optional flag specifying whether or not to split the view horizontally. The
155
- default value is `false`, comparing the two files side-by-side.
156
154
157
155
158
- ---
0 commit comments