Skip to content

Commit 6d79e26

Browse files
author
CNCoderX
committed
20171204
1 parent 2ab32b0 commit 6d79e26

File tree

445 files changed

+69734
-2615
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

445 files changed

+69734
-2615
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
<activity android:name=".ui.activity.RepositoryActivity"
4848
android:label="@string/repositories">
4949
</activity>
50-
<activity android:name=".ui.activity.TextFileReviewActivity"
50+
<activity android:name=".ui.activity.CodeReviewActivity"
5151
android:label="">
5252
</activity>
5353
<activity android:name=".ui.activity.IssueCommentActivity"
@@ -77,6 +77,9 @@
7777
<activity android:name=".ui.activity.SettingActivity"
7878
android:label="@string/settings">
7979
</activity>
80+
<activity android:name=".ui.activity.CodeStyleSettingActivity"
81+
android:label="@string/code_style">
82+
</activity>
8083
<activity android:name=".ui.activity.RepoListActivity"
8184
android:label="@string/repositories">
8285
</activity>

app/src/main/assets/Arial.ttf

-12.8 MB
Binary file not shown.
Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
2+
// Distributed under an MIT license: http://codemirror.net/LICENSE
3+
4+
(function(mod) {
5+
if (typeof exports == "object" && typeof module == "object") // CommonJS
6+
mod(require("../../lib/codemirror"));
7+
else if (typeof define == "function" && define.amd) // AMD
8+
define(["../../lib/codemirror"], mod);
9+
else // Plain browser env
10+
mod(CodeMirror);
11+
})(function(CodeMirror) {
12+
"use strict";
13+
14+
var noOptions = {};
15+
var nonWS = /[^\s\u00a0]/;
16+
var Pos = CodeMirror.Pos;
17+
18+
function firstNonWS(str) {
19+
var found = str.search(nonWS);
20+
return found == -1 ? 0 : found;
21+
}
22+
23+
CodeMirror.commands.toggleComment = function(cm) {
24+
cm.toggleComment();
25+
};
26+
27+
CodeMirror.defineExtension("toggleComment", function(options) {
28+
if (!options) options = noOptions;
29+
var cm = this;
30+
var minLine = Infinity, ranges = this.listSelections(), mode = null;
31+
for (var i = ranges.length - 1; i >= 0; i--) {
32+
var from = ranges[i].from(), to = ranges[i].to();
33+
if (from.line >= minLine) continue;
34+
if (to.line >= minLine) to = Pos(minLine, 0);
35+
minLine = from.line;
36+
if (mode == null) {
37+
if (cm.uncomment(from, to, options)) mode = "un";
38+
else { cm.lineComment(from, to, options); mode = "line"; }
39+
} else if (mode == "un") {
40+
cm.uncomment(from, to, options);
41+
} else {
42+
cm.lineComment(from, to, options);
43+
}
44+
}
45+
});
46+
47+
// Rough heuristic to try and detect lines that are part of multi-line string
48+
function probablyInsideString(cm, pos, line) {
49+
return /\bstring\b/.test(cm.getTokenTypeAt(Pos(pos.line, 0))) && !/^[\'\"`]/.test(line)
50+
}
51+
52+
CodeMirror.defineExtension("lineComment", function(from, to, options) {
53+
if (!options) options = noOptions;
54+
var self = this, mode = self.getModeAt(from);
55+
var firstLine = self.getLine(from.line);
56+
if (firstLine == null || probablyInsideString(self, from, firstLine)) return;
57+
58+
var commentString = options.lineComment || mode.lineComment;
59+
if (!commentString) {
60+
if (options.blockCommentStart || mode.blockCommentStart) {
61+
options.fullLines = true;
62+
self.blockComment(from, to, options);
63+
}
64+
return;
65+
}
66+
67+
var end = Math.min(to.ch != 0 || to.line == from.line ? to.line + 1 : to.line, self.lastLine() + 1);
68+
var pad = options.padding == null ? " " : options.padding;
69+
var blankLines = options.commentBlankLines || from.line == to.line;
70+
71+
self.operation(function() {
72+
if (options.indent) {
73+
var baseString = null;
74+
for (var i = from.line; i < end; ++i) {
75+
var line = self.getLine(i);
76+
var whitespace = line.slice(0, firstNonWS(line));
77+
if (baseString == null || baseString.length > whitespace.length) {
78+
baseString = whitespace;
79+
}
80+
}
81+
for (var i = from.line; i < end; ++i) {
82+
var line = self.getLine(i), cut = baseString.length;
83+
if (!blankLines && !nonWS.test(line)) continue;
84+
if (line.slice(0, cut) != baseString) cut = firstNonWS(line);
85+
self.replaceRange(baseString + commentString + pad, Pos(i, 0), Pos(i, cut));
86+
}
87+
} else {
88+
for (var i = from.line; i < end; ++i) {
89+
if (blankLines || nonWS.test(self.getLine(i)))
90+
self.replaceRange(commentString + pad, Pos(i, 0));
91+
}
92+
}
93+
});
94+
});
95+
96+
CodeMirror.defineExtension("blockComment", function(from, to, options) {
97+
if (!options) options = noOptions;
98+
var self = this, mode = self.getModeAt(from);
99+
var startString = options.blockCommentStart || mode.blockCommentStart;
100+
var endString = options.blockCommentEnd || mode.blockCommentEnd;
101+
if (!startString || !endString) {
102+
if ((options.lineComment || mode.lineComment) && options.fullLines != false)
103+
self.lineComment(from, to, options);
104+
return;
105+
}
106+
if (/\bcomment\b/.test(self.getTokenTypeAt(Pos(from.line, 0)))) return
107+
108+
var end = Math.min(to.line, self.lastLine());
109+
if (end != from.line && to.ch == 0 && nonWS.test(self.getLine(end))) --end;
110+
111+
var pad = options.padding == null ? " " : options.padding;
112+
if (from.line > end) return;
113+
114+
self.operation(function() {
115+
if (options.fullLines != false) {
116+
var lastLineHasText = nonWS.test(self.getLine(end));
117+
self.replaceRange(pad + endString, Pos(end));
118+
self.replaceRange(startString + pad, Pos(from.line, 0));
119+
var lead = options.blockCommentLead || mode.blockCommentLead;
120+
if (lead != null) for (var i = from.line + 1; i <= end; ++i)
121+
if (i != end || lastLineHasText)
122+
self.replaceRange(lead + pad, Pos(i, 0));
123+
} else {
124+
self.replaceRange(endString, to);
125+
self.replaceRange(startString, from);
126+
}
127+
});
128+
});
129+
130+
CodeMirror.defineExtension("uncomment", function(from, to, options) {
131+
if (!options) options = noOptions;
132+
var self = this, mode = self.getModeAt(from);
133+
var end = Math.min(to.ch != 0 || to.line == from.line ? to.line : to.line - 1, self.lastLine()), start = Math.min(from.line, end);
134+
135+
// Try finding line comments
136+
var lineString = options.lineComment || mode.lineComment, lines = [];
137+
var pad = options.padding == null ? " " : options.padding, didSomething;
138+
lineComment: {
139+
if (!lineString) break lineComment;
140+
for (var i = start; i <= end; ++i) {
141+
var line = self.getLine(i);
142+
var found = line.indexOf(lineString);
143+
if (found > -1 && !/comment/.test(self.getTokenTypeAt(Pos(i, found + 1)))) found = -1;
144+
if (found == -1 && nonWS.test(line)) break lineComment;
145+
if (found > -1 && nonWS.test(line.slice(0, found))) break lineComment;
146+
lines.push(line);
147+
}
148+
self.operation(function() {
149+
for (var i = start; i <= end; ++i) {
150+
var line = lines[i - start];
151+
var pos = line.indexOf(lineString), endPos = pos + lineString.length;
152+
if (pos < 0) continue;
153+
if (line.slice(endPos, endPos + pad.length) == pad) endPos += pad.length;
154+
didSomething = true;
155+
self.replaceRange("", Pos(i, pos), Pos(i, endPos));
156+
}
157+
});
158+
if (didSomething) return true;
159+
}
160+
161+
// Try block comments
162+
var startString = options.blockCommentStart || mode.blockCommentStart;
163+
var endString = options.blockCommentEnd || mode.blockCommentEnd;
164+
if (!startString || !endString) return false;
165+
var lead = options.blockCommentLead || mode.blockCommentLead;
166+
var startLine = self.getLine(start), open = startLine.indexOf(startString)
167+
if (open == -1) return false
168+
var endLine = end == start ? startLine : self.getLine(end)
169+
var close = endLine.indexOf(endString, end == start ? open + startString.length : 0);
170+
if (close == -1 && start != end) {
171+
endLine = self.getLine(--end);
172+
close = endLine.indexOf(endString);
173+
}
174+
if (close == -1 ||
175+
!/comment/.test(self.getTokenTypeAt(Pos(start, open + 1))) ||
176+
!/comment/.test(self.getTokenTypeAt(Pos(end, close + 1))))
177+
return false;
178+
179+
// Avoid killing block comments completely outside the selection.
180+
// Positions of the last startString before the start of the selection, and the first endString after it.
181+
var lastStart = startLine.lastIndexOf(startString, from.ch);
182+
var firstEnd = lastStart == -1 ? -1 : startLine.slice(0, from.ch).indexOf(endString, lastStart + startString.length);
183+
if (lastStart != -1 && firstEnd != -1 && firstEnd + endString.length != from.ch) return false;
184+
// Positions of the first endString after the end of the selection, and the last startString before it.
185+
firstEnd = endLine.indexOf(endString, to.ch);
186+
var almostLastStart = endLine.slice(to.ch).lastIndexOf(startString, firstEnd - to.ch);
187+
lastStart = (firstEnd == -1 || almostLastStart == -1) ? -1 : to.ch + almostLastStart;
188+
if (firstEnd != -1 && lastStart != -1 && lastStart != to.ch) return false;
189+
190+
self.operation(function() {
191+
self.replaceRange("", Pos(end, close - (pad && endLine.slice(close - pad.length, close) == pad ? pad.length : 0)),
192+
Pos(end, close + endString.length));
193+
var openEnd = open + startString.length;
194+
if (pad && startLine.slice(openEnd, openEnd + pad.length) == pad) openEnd += pad.length;
195+
self.replaceRange("", Pos(start, open), Pos(start, openEnd));
196+
if (lead) for (var i = start + 1; i <= end; ++i) {
197+
var line = self.getLine(i), found = line.indexOf(lead);
198+
if (found == -1 || nonWS.test(line.slice(0, found))) continue;
199+
var foundEnd = found + lead.length;
200+
if (pad && line.slice(foundEnd, foundEnd + pad.length) == pad) foundEnd += pad.length;
201+
self.replaceRange("", Pos(i, found), Pos(i, foundEnd));
202+
}
203+
});
204+
return true;
205+
});
206+
});
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
2+
// Distributed under an MIT license: http://codemirror.net/LICENSE
3+
4+
(function(mod) {
5+
if (typeof exports == "object" && typeof module == "object") // CommonJS
6+
mod(require("../../lib/codemirror"));
7+
else if (typeof define == "function" && define.amd) // AMD
8+
define(["../../lib/codemirror"], mod);
9+
else // Plain browser env
10+
mod(CodeMirror);
11+
})(function(CodeMirror) {
12+
var modes = ["clike", "css", "javascript"];
13+
14+
for (var i = 0; i < modes.length; ++i)
15+
CodeMirror.extendMode(modes[i], {blockCommentContinue: " * "});
16+
17+
function continueComment(cm) {
18+
if (cm.getOption("disableInput")) return CodeMirror.Pass;
19+
var ranges = cm.listSelections(), mode, inserts = [];
20+
for (var i = 0; i < ranges.length; i++) {
21+
var pos = ranges[i].head, token = cm.getTokenAt(pos);
22+
if (token.type != "comment") return CodeMirror.Pass;
23+
var modeHere = CodeMirror.innerMode(cm.getMode(), token.state).mode;
24+
if (!mode) mode = modeHere;
25+
else if (mode != modeHere) return CodeMirror.Pass;
26+
27+
var insert = null;
28+
if (mode.blockCommentStart && mode.blockCommentContinue) {
29+
var end = token.string.indexOf(mode.blockCommentEnd);
30+
var full = cm.getRange(CodeMirror.Pos(pos.line, 0), CodeMirror.Pos(pos.line, token.end)), found;
31+
if (end != -1 && end == token.string.length - mode.blockCommentEnd.length && pos.ch >= end) {
32+
// Comment ended, don't continue it
33+
} else if (token.string.indexOf(mode.blockCommentStart) == 0) {
34+
insert = full.slice(0, token.start);
35+
if (!/^\s*$/.test(insert)) {
36+
insert = "";
37+
for (var j = 0; j < token.start; ++j) insert += " ";
38+
}
39+
} else if ((found = full.indexOf(mode.blockCommentContinue)) != -1 &&
40+
found + mode.blockCommentContinue.length > token.start &&
41+
/^\s*$/.test(full.slice(0, found))) {
42+
insert = full.slice(0, found);
43+
}
44+
if (insert != null) insert += mode.blockCommentContinue;
45+
}
46+
if (insert == null && mode.lineComment && continueLineCommentEnabled(cm)) {
47+
var line = cm.getLine(pos.line), found = line.indexOf(mode.lineComment);
48+
if (found > -1) {
49+
insert = line.slice(0, found);
50+
if (/\S/.test(insert)) insert = null;
51+
else insert += mode.lineComment + line.slice(found + mode.lineComment.length).match(/^\s*/)[0];
52+
}
53+
}
54+
if (insert == null) return CodeMirror.Pass;
55+
inserts[i] = "\n" + insert;
56+
}
57+
58+
cm.operation(function() {
59+
for (var i = ranges.length - 1; i >= 0; i--)
60+
cm.replaceRange(inserts[i], ranges[i].from(), ranges[i].to(), "+insert");
61+
});
62+
}
63+
64+
function continueLineCommentEnabled(cm) {
65+
var opt = cm.getOption("continueComments");
66+
if (opt && typeof opt == "object")
67+
return opt.continueLineComment !== false;
68+
return true;
69+
}
70+
71+
CodeMirror.defineOption("continueComments", null, function(cm, val, prev) {
72+
if (prev && prev != CodeMirror.Init)
73+
cm.removeKeyMap("continueComment");
74+
if (val) {
75+
var key = "Enter";
76+
if (typeof val == "string")
77+
key = val;
78+
else if (typeof val == "object" && val.key)
79+
key = val.key;
80+
var map = {name: "continueComment"};
81+
map[key] = continueComment;
82+
cm.addKeyMap(map);
83+
}
84+
});
85+
});
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
.CodeMirror-dialog {
2+
position: absolute;
3+
left: 0; right: 0;
4+
background: inherit;
5+
z-index: 15;
6+
padding: .1em .8em;
7+
overflow: hidden;
8+
color: inherit;
9+
}
10+
11+
.CodeMirror-dialog-top {
12+
border-bottom: 1px solid #eee;
13+
top: 0;
14+
}
15+
16+
.CodeMirror-dialog-bottom {
17+
border-top: 1px solid #eee;
18+
bottom: 0;
19+
}
20+
21+
.CodeMirror-dialog input {
22+
border: none;
23+
outline: none;
24+
background: transparent;
25+
width: 20em;
26+
color: inherit;
27+
font-family: monospace;
28+
}
29+
30+
.CodeMirror-dialog button {
31+
font-size: 70%;
32+
}

0 commit comments

Comments
 (0)