@@ -5,21 +5,24 @@ Two-way file comparison for Textadept.
55Install this module by copying it into your * ~ /.textadept/modules/* directory or Textadept's
66* modules/* directory, and then putting the following in your * ~ /.textadept/init.lua* :
77
8- require('file_diff')
8+ ``` lua
9+ local file_diff = require (' file_diff' )
10+ ```
911
1012## Compiling
1113
1214Releases include binaries, so building this modules should not be necessary. If you want
1315to build manually, use CMake. For example:
1416
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+ ```
1822
1923## Usage
2024
2125A sample workflow is this:
22-
23261 . Start comparing two files via the "Compare Files" submenu in the "Tools" menu.
24272 . The caret is initially placed in the file on the left.
25283 . Go to the next change via menu or key binding.
@@ -46,113 +49,107 @@ Ctrl+Alt+, | ^⌘, | None | Goto previous difference
4649Ctrl+Alt+< | ^⌘< | None | Merge left
4750Ctrl+Alt+> | ^⌘> | None | Merge right
4851
49- ## Fields defined by ` file_diff `
50-
5152<a id =" file_diff.INDIC_ADDITION " ></a >
52- ### ` file_diff.INDIC_ADDITION `
53+ ## ` file_diff.INDIC_ADDITION `
5354
5455The indicator number for text added within lines.
5556
5657<a id =" file_diff.INDIC_DELETION " ></a >
57- ### ` file_diff.INDIC_DELETION `
58+ ## ` file_diff.INDIC_DELETION `
5859
5960The indicator number for text deleted within lines.
6061
6162<a id =" file_diff.MARK_ADDITION " ></a >
62- ### ` file_diff.MARK_ADDITION `
63+ ## ` file_diff.MARK_ADDITION `
6364
6465The marker for line additions.
6566
6667<a id =" file_diff.MARK_DELETION " ></a >
67- ### ` file_diff.MARK_DELETION `
68+ ## ` file_diff.MARK_DELETION `
6869
6970The marker for line deletions.
7071
7172<a id =" file_diff.MARK_MODIFICATION " ></a >
72- ### ` file_diff.MARK_MODIFICATION `
73+ ## ` file_diff.MARK_MODIFICATION `
7374
7475The marker for line modifications.
7576
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-
10077<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.
10281
103- Returns a list that represents the differences between strings * text1* and * text2* .
10482Each consecutive pair of elements in the returned list represents a "diff". The first element
10583is an integer: 0 for a deletion, 1 for an insertion, and 2 for equality. The second element
10684is the associated diff text.
10785
10886Parameters:
109-
11087- * text1* : String to compare against.
11188- * text2* : String to compare.
11289
11390Usage:
11491
115- - `diffs = diff(text1, text2)
92+ ``` lua
93+ diffs = diff (text1 , text2 )
11694 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 `
118107
119- Return:
108+ The name of the theme color used to mark deletions.
120109
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.
122112
123113<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.
125117
126- Jumps to the next or previous difference between the two files depending on boolean * next* .
127118[ ` file_diff.start() ` ] ( #file_diff.start ) must have been called previously.
128119
129120Parameters:
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 .
132123
133124<a id =" file_diff.merge " ></a >
134- ### ` file_diff.merge ` (* left* )
125+ ## ` file_diff.merge ` ([ * left* =false ] )
135126
136127Merges a change from one buffer to another, depending on the change under the caret and the
137128merge direction.
138129
139130Parameters:
131+ - * left* : Merge from right to left as opposed to left to right.
140132
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.
142140
143141<a id =" file_diff.start " ></a >
144- ### ` file_diff.start ` (* file1* , * file2* , * horizontal* )
142+ ## ` file_diff.start ` ([ * file1* [ , * file2* [ , * horizontal* =false ]]] )
145143
146- Highlight differences between files * file1 * and * file2 * , or the user-selected files .
144+ Highlight differences between files.
147145
148146Parameters:
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.
149153
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.
156154
157155
158- ---
0 commit comments