Skip to content

Commit 375d44b

Browse files
committed
Initial pass reformatting all code.
Use clang-format, LuaFormatter, and 100 character limit on lines.
1 parent ba8dd32 commit 375d44b

File tree

5 files changed

+141
-200
lines changed

5 files changed

+141
-200
lines changed

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License
22

3-
Copyright (c) 2015-2020 Mitchell
3+
Copyright (c) 2015-2021 Mitchell
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

Makefile

+4-8
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,15 @@ CROSS_OSX = x86_64-apple-darwin17-c++
1818

1919
diff.so: diff.o ; $(CXX) -shared $(CXXFLAGS) -o $@ $^ $(LDFLAGS)
2020
diff.dll: diff-win.o lua.la
21-
$(CROSS_WIN)$(CXX) -shared -static-libgcc -static-libstdc++ $(CXXFLAGS) -o \
22-
$@ $^ $(LDFLAGS)
21+
$(CROSS_WIN)$(CXX) -shared -static-libgcc -static-libstdc++ $(CXXFLAGS) -o $@ $^ $(LDFLAGS)
2322
diff-curses.dll: diff-win.o lua-curses.la
24-
$(CROSS_WIN)$(CXX) -shared -static-libgcc -static-libstdc++ $(CXXFLAGS) -o \
25-
$@ $^ $(LDFLAGS)
23+
$(CROSS_WIN)$(CXX) -shared -static-libgcc -static-libstdc++ $(CXXFLAGS) -o $@ $^ $(LDFLAGS)
2624
diffosx.so: diff-osx.o
2725
$(CROSS_OSX) -shared $(CXXFLAGS_OSX) -undefined dynamic_lookup -o $@ $^
2826

2927
diff.o: diff.cxx ; $(CXX) -c $(CXXFLAGS) -I$(ta_lua) -o $@ $^
3028
diff-win.o: diff.cxx
31-
$(CROSS_WIN)$(CXX) -c $(CXXFLAGS) -DLUA_BUILD_AS_DLL -DLUA_LIB -I$(ta_lua) \
32-
-o $@ $^
29+
$(CROSS_WIN)$(CXX) -c $(CXXFLAGS) -DLUA_BUILD_AS_DLL -DLUA_LIB -I$(ta_lua) -o $@ $^
3330
diff-osx.o: diff.cxx ; $(CROSS_OSX) -c $(CXXFLAGS_OSX) -I$(ta_lua) -o $@ $^
3431

3532
lua.def:
@@ -58,8 +55,7 @@ luadoc: init.lua
5855
deps: diff_match_patch.h
5956

6057
diff_match_patch_zip = 7f95b37e554453262e2bcda830724fc362614103.zip
61-
$(diff_match_patch_zip):
62-
wget https://github.com/leutloff/diff-match-patch-cpp-stl/archive/$@
58+
$(diff_match_patch_zip): ; wget https://github.com/leutloff/diff-match-patch-cpp-stl/archive/$@
6359
diff_match_patch.h: | $(diff_match_patch_zip) ; unzip -j $| "*/$@"
6460

6561
# Releases.

README.md

+36-45
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,39 @@
22

33
Two-way file comparison for Textadept.
44

5-
Install this module by copying it into your *~/.textadept/modules/* directory
6-
or Textadept's *modules/* directory, and then putting the following in your
7-
*~/.textadept/init.lua*:
5+
Install this module by copying it into your *~/.textadept/modules/* directory or Textadept's
6+
*modules/* directory, and then putting the following in your *~/.textadept/init.lua*:
87

98
require('file_diff')
109

1110
## Usage
1211

1312
A sample workflow is this:
1413

15-
1. Start comparing two files via the "Compare Files" submenu in the "Tools"
16-
menu.
14+
1. Start comparing two files via the "Compare Files" submenu in the "Tools" menu.
1715
2. The caret is initially placed in the file on the left.
1816
3. Go to the next change via menu or key binding.
19-
4. Merge the change from the other buffer into the current one (right to
20-
left) via menu or key binding.
17+
4. Merge the change from the other buffer into the current one (right to left) via menu or
18+
key binding.
2119
5. Go to the next change via menu or key binding.
22-
6. Merge the change from the current buffer into the other one (left to
23-
right) via menu or key binding.
20+
6. Merge the change from the current buffer into the other one (left to right) via menu or
21+
key binding.
2422
7. Repeat as necessary.
2523

26-
Note: merging can be performed wherever the caret is placed when jumping
27-
between changes, even if one buffer has a change and the other does not
28-
(additions or deletions).
24+
Note: merging can be performed wherever the caret is placed when jumping between changes,
25+
even if one buffer has a change and the other does not (additions or deletions).
2926

3027
## Key Bindings
3128

32-
Windows, Linux, BSD|macOS|Terminal|Command
33-
-------------------|-----|--------|-------
34-
**Tools** | | |
35-
F6 |F6 |F6 |Compare files...
36-
Shift+F6 |⇧F6 |S-F6 |Compare the buffers in two split views
37-
Alt+Down |⌥⇣ |M-Down |Goto next difference
38-
Alt+Up |⌥⇡ |M-Up |Goto previous difference
39-
Alt+Left |⌥⇠ |M-Left |Merge left
40-
Alt+Right |⌥⇢ |M-Right |Merge right
29+
Windows, Linux, BSD | macOS | Terminal | Command
30+
-|-|-|-
31+
**Tools**| | |
32+
F6 | F6 | F6 | Compare files...
33+
Shift+F6 | ⇧F6 | S-F6 | Compare the buffers in two split views
34+
Alt+Down | ⌥⇣ | M-Down | Goto next difference
35+
Alt+Up | ⌥⇡ | M-Up | Goto previous difference
36+
Alt+Left | ⌥⇠ | M-Left | Merge left
37+
Alt+Right | ⌥⇢ | M-Right | Merge right
4138

4239

4340
## Fields defined by `file_diff`
@@ -71,10 +68,9 @@ The marker for line modifications.
7168
### `file_diff.theme` (string)
7269

7370
The theme to use, either 'dark' or 'light'.
74-
This is not the theme used with Textadept.
75-
Depending on this setting, additions will be colored 'dark_green' or
76-
'light_green', deletions will be colored 'dark_red' or 'light_red', and so
77-
on.
71+
This is not the theme used with Textadept. Depending on this setting, additions will be
72+
colored 'dark_green' or 'light_green', deletions will be colored 'dark_red' or 'light_red',
73+
and so on.
7874
The default value is auto-detected.
7975

8076

@@ -83,11 +79,10 @@ The theme to use, either 'dark' or 'light'.
8379
<a id="_G.diff"></a>
8480
### `_G.diff`(*text1, text2*)
8581

86-
Returns a list that represents the differences between strings *text1* and
87-
*text2*.
88-
Each consecutive pair of elements in the returned list represents a "diff".
89-
The first element is an integer: 0 for a deletion, 1 for an insertion, and 2
90-
for equality. The second element is the associated diff text.
82+
Returns a list that represents the differences between strings *text1* and *text2*.
83+
Each consecutive pair of elements in the returned list represents a "diff". The first element
84+
is an integer: 0 for a deletion, 1 for an insertion, and 2 for equality. The second element
85+
is the associated diff text.
9186

9287
Parameters:
9388

@@ -106,20 +101,18 @@ Return:
106101
<a id="file_diff.goto_change"></a>
107102
### `file_diff.goto_change`(*next*)
108103

109-
Jumps to the next or previous difference between the two files depending on
110-
boolean *next*.
104+
Jumps to the next or previous difference between the two files depending on boolean *next*.
111105
[`file_diff.start()`](#file_diff.start) must have been called previously.
112106

113107
Parameters:
114108

115-
* *`next`*: Whether to go to the next or previous difference relative to the
116-
current line.
109+
* *`next`*: Whether to go to the next or previous difference relative to the current line.
117110

118111
<a id="file_diff.merge"></a>
119112
### `file_diff.merge`(*left*)
120113

121-
Merges a change from one buffer to another, depending on the change under
122-
the caret and the merge direction.
114+
Merges a change from one buffer to another, depending on the change under the caret and the
115+
merge direction.
123116

124117
Parameters:
125118

@@ -128,18 +121,16 @@ Parameters:
128121
<a id="file_diff.start"></a>
129122
### `file_diff.start`(*file1, file2, horizontal*)
130123

131-
Highlight differences between files *file1* and *file2*, or the user-selected
132-
files.
124+
Highlight differences between files *file1* and *file2*, or the user-selected files.
133125

134126
Parameters:
135127

136-
* *`file1`*: Optional name of the older file. If `-`, uses the current
137-
buffer. If `nil`, the user is prompted for a file.
138-
* *`file2`*: Optional name of the newer file. If `-`, uses the current
139-
buffer. If `nil`, the user is prompted for a file.
140-
* *`horizontal`*: Optional flag specifying whether or not to split the view
141-
horizontally. The default value is `false`, comparing the two files
142-
side-by-side.
128+
* *`file1`*: Optional name of the older file. If `-`, uses the current buffer. If `nil`,
129+
the user is prompted for a file.
130+
* *`file2`*: Optional name of the newer file. If `-`, uses the current buffer. If `nil`,
131+
the user is prompted for a file.
132+
* *`horizontal`*: Optional flag specifying whether or not to split the view horizontally. The
133+
default value is `false`, comparing the two files side-by-side.
143134

144135

145136
---

diff.cxx

+5-12
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,21 @@ extern "C" {
1111
/** diff() Lua function. */
1212
static int diff(lua_State *L) {
1313
diff_match_patch<std::string> dmp;
14-
auto diffs = dmp.diff_main(
15-
luaL_checkstring(L, 1), luaL_checkstring(L, 2), false);
14+
auto diffs = dmp.diff_main(luaL_checkstring(L, 1), luaL_checkstring(L, 2), false);
1615
dmp.diff_cleanupSemantic(diffs);
1716
lua_createtable(L, diffs.size() * 2, 0);
1817
int len = 1;
19-
for(auto& diff : diffs) {
18+
for (auto &diff : diffs) {
2019
lua_pushnumber(L, diff.operation), lua_rawseti(L, -2, len++);
2120
lua_pushstring(L, diff.text.c_str()), lua_rawseti(L, -2, len++);
2221
}
2322
return 1;
2423
}
2524

2625
extern "C" {
27-
int luaopen_diff(lua_State *L) {
28-
return (lua_pushcfunction(L, diff), 1);
29-
}
26+
int luaopen_diff(lua_State *L) { return (lua_pushcfunction(L, diff), 1); }
3027

3128
// Platform-specific Lua library entry points.
32-
LUALIB_API int luaopen_file_diff_diff(lua_State *L) {
33-
return luaopen_diff(L);
34-
}
35-
LUALIB_API int luaopen_file_diff_diffosx(lua_State *L) {
36-
return luaopen_diff(L);
37-
}
29+
LUALIB_API int luaopen_file_diff_diff(lua_State *L) { return luaopen_diff(L); }
30+
LUALIB_API int luaopen_file_diff_diffosx(lua_State *L) { return luaopen_diff(L); }
3831
}

0 commit comments

Comments
 (0)