Remove unused code
This commit is contained in:
parent
4e34e9e1d8
commit
a5d326b8c3
|
@ -1,5 +1,6 @@
|
||||||
# Miscellaneous
|
# Miscellaneous
|
||||||
*.class
|
*.class
|
||||||
|
example.md
|
||||||
*.log
|
*.log
|
||||||
*.pyc
|
*.pyc
|
||||||
*.swp
|
*.swp
|
||||||
|
|
132
lib/file.dart
132
lib/file.dart
|
@ -7,7 +7,6 @@ import 'package:subwrite/annotation.dart';
|
||||||
|
|
||||||
import 'package:subwrite/section.dart';
|
import 'package:subwrite/section.dart';
|
||||||
import 'package:subwrite/sourcelink.dart';
|
import 'package:subwrite/sourcelink.dart';
|
||||||
import 'package:subwrite/suggestion.dart';
|
|
||||||
import 'cursor_provider.dart';
|
import 'cursor_provider.dart';
|
||||||
import 'line_info.dart';
|
import 'line_info.dart';
|
||||||
|
|
||||||
|
@ -42,106 +41,42 @@ class LineFile extends ChangeNotifier {
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
void cancelSuggestions() {
|
|
||||||
if (showSuggestions) {
|
|
||||||
suggestionIndex = 0;
|
|
||||||
showSuggestions = false;
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ScrollController suggestionListController = ScrollController(initialScrollOffset: 0.0);
|
|
||||||
int suggestionIndex = 0;
|
|
||||||
List<Suggestion> suggestions = List.empty();
|
|
||||||
|
|
||||||
// Future<List<Suggestion>> loadSuggestions(IDE ide) async {
|
|
||||||
// return ide.getSuggestions(projectPath, path, cursor.line, cursor.column, base64()).then((list) {
|
|
||||||
// suggestions = list;
|
|
||||||
// return list;
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
void suggestListUp() {
|
|
||||||
suggestionIndex = (suggestionIndex - 1) % suggestions.length;
|
|
||||||
if (suggestions.length - suggestionIndex >= 14 || suggestionIndex == 0 || suggestionIndex == suggestions.length - 1) {
|
|
||||||
suggestionListController.animateTo(suggestionIndex * 13.0, duration: const Duration(milliseconds: 100), curve: Curves.decelerate);
|
|
||||||
}
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
void suggestListDown() {
|
|
||||||
suggestionIndex = (suggestionIndex + 1) % suggestions.length;
|
|
||||||
if (suggestions.length - suggestionIndex >= 14 || suggestionIndex == 0 || suggestionIndex == suggestions.length - 1) {
|
|
||||||
suggestionListController.animateTo(suggestionIndex * 13.0, duration: const Duration(milliseconds: 100), curve: Curves.decelerate);
|
|
||||||
}
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
void suggestListInsert() {
|
|
||||||
suggestionIndex = (suggestionIndex) % suggestions.length;
|
|
||||||
for (var char = suggestions[suggestionIndex].partialLen; char < suggestions[suggestionIndex].name.length; char++) {
|
|
||||||
insertChar(suggestions[suggestionIndex].name[char]);
|
|
||||||
}
|
|
||||||
cursor.publishCursor(backingLines);
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
KeyEventResult handleKey(RawKeyEvent event) {
|
KeyEventResult handleKey(RawKeyEvent event) {
|
||||||
// only process key down events...
|
// only process key down events...
|
||||||
if (event.runtimeType.toString() == 'RawKeyDownEvent') {
|
if (event.runtimeType.toString() == 'RawKeyDownEvent') {
|
||||||
if (event.logicalKey == LogicalKeyboardKey.arrowLeft) {
|
if (event.logicalKey == LogicalKeyboardKey.arrowLeft) {
|
||||||
cursor.moveCursor(-1, 0, backingLines, keepAnchor: event.isShiftPressed);
|
cursor.moveCursor(-1, 0, backingLines, keepAnchor: event.isShiftPressed);
|
||||||
cursor.publishCursor(backingLines);
|
cursor.publishCursor(backingLines);
|
||||||
cancelSuggestions();
|
|
||||||
} else if (event.logicalKey == LogicalKeyboardKey.arrowRight) {
|
} else if (event.logicalKey == LogicalKeyboardKey.arrowRight) {
|
||||||
cursor.moveCursor(1, 0, backingLines, keepAnchor: event.isShiftPressed);
|
cursor.moveCursor(1, 0, backingLines, keepAnchor: event.isShiftPressed);
|
||||||
cursor.publishCursor(backingLines);
|
cursor.publishCursor(backingLines);
|
||||||
cancelSuggestions();
|
|
||||||
} else if (event.logicalKey == LogicalKeyboardKey.arrowUp) {
|
} else if (event.logicalKey == LogicalKeyboardKey.arrowUp) {
|
||||||
if (showSuggestions == false) {
|
cursor.moveCursor(0, -1, backingLines, keepAnchor: event.isShiftPressed);
|
||||||
cursor.moveCursor(0, -1, backingLines, keepAnchor: event.isShiftPressed);
|
cursor.publishCursor(backingLines);
|
||||||
cursor.publishCursor(backingLines);
|
|
||||||
} else {
|
|
||||||
suggestListUp();
|
|
||||||
}
|
|
||||||
} else if (event.logicalKey == LogicalKeyboardKey.arrowDown) {
|
} else if (event.logicalKey == LogicalKeyboardKey.arrowDown) {
|
||||||
if (showSuggestions == false) {
|
cursor.moveCursor(0, 1, backingLines, keepAnchor: event.isShiftPressed);
|
||||||
cursor.moveCursor(0, 1, backingLines, keepAnchor: event.isShiftPressed);
|
cursor.publishCursor(backingLines);
|
||||||
cursor.publishCursor(backingLines);
|
|
||||||
} else {
|
|
||||||
suggestListDown();
|
|
||||||
}
|
|
||||||
} else if (event.logicalKey == LogicalKeyboardKey.home) {
|
} else if (event.logicalKey == LogicalKeyboardKey.home) {
|
||||||
cancelSuggestions();
|
|
||||||
cursor.clearSelection();
|
cursor.clearSelection();
|
||||||
cursor.moveCursorToLineStart();
|
cursor.moveCursorToLineStart();
|
||||||
cursor.publishCursor(backingLines);
|
cursor.publishCursor(backingLines);
|
||||||
} else if (event.logicalKey == LogicalKeyboardKey.end) {
|
} else if (event.logicalKey == LogicalKeyboardKey.end) {
|
||||||
cancelSuggestions();
|
|
||||||
cursor.clearSelection();
|
cursor.clearSelection();
|
||||||
cursor.moveCursorToLineEnd(backingLines[cursor.line - 1].text.length);
|
cursor.moveCursorToLineEnd(backingLines[cursor.line - 1].text.length);
|
||||||
cursor.publishCursor(backingLines);
|
cursor.publishCursor(backingLines);
|
||||||
} else if (event.logicalKey == LogicalKeyboardKey.enter) {
|
} else if (event.logicalKey == LogicalKeyboardKey.enter) {
|
||||||
if (showSuggestions == false) {
|
insertLine();
|
||||||
insertLine();
|
cursor.clearSelection();
|
||||||
cancelSuggestions();
|
cursor.publishCursor(backingLines);
|
||||||
cursor.clearSelection();
|
|
||||||
cursor.publishCursor(backingLines);
|
|
||||||
} else {
|
|
||||||
suggestListInsert();
|
|
||||||
}
|
|
||||||
} else if (event.logicalKey == LogicalKeyboardKey.tab) {
|
} else if (event.logicalKey == LogicalKeyboardKey.tab) {
|
||||||
insertChar(" ");
|
insertChar(" ");
|
||||||
cancelSuggestions();
|
|
||||||
cursor.publishCursor(backingLines);
|
cursor.publishCursor(backingLines);
|
||||||
} else if (event.logicalKey == LogicalKeyboardKey.delete) {
|
} else if (event.logicalKey == LogicalKeyboardKey.delete) {
|
||||||
handleDelete();
|
handleDelete();
|
||||||
cancelSuggestions();
|
|
||||||
cursor.clearSelection();
|
cursor.clearSelection();
|
||||||
cursor.publishCursor(backingLines);
|
cursor.publishCursor(backingLines);
|
||||||
} else if (event.logicalKey == LogicalKeyboardKey.backspace) {
|
} else if (event.logicalKey == LogicalKeyboardKey.backspace) {
|
||||||
handleBackspace();
|
handleBackspace();
|
||||||
cancelSuggestions();
|
|
||||||
cursor.clearSelection();
|
cursor.clearSelection();
|
||||||
cursor.publishCursor(backingLines);
|
cursor.publishCursor(backingLines);
|
||||||
} else if (event.logicalKey == LogicalKeyboardKey.escape) {
|
} else if (event.logicalKey == LogicalKeyboardKey.escape) {
|
||||||
|
@ -311,7 +246,6 @@ class LineFile extends ChangeNotifier {
|
||||||
|
|
||||||
// rebuild the annotations manager
|
// rebuild the annotations manager
|
||||||
void parse() {
|
void parse() {
|
||||||
|
|
||||||
sections.clear();
|
sections.clear();
|
||||||
|
|
||||||
for (var i = 0; i < backingLines.length; i++) {
|
for (var i = 0; i < backingLines.length; i++) {
|
||||||
|
@ -320,19 +254,22 @@ class LineFile extends ChangeNotifier {
|
||||||
backingLines[i].annotations.removeWhere((element) => element.tool == "markdown");
|
backingLines[i].annotations.removeWhere((element) => element.tool == "markdown");
|
||||||
|
|
||||||
if (line.text.startsWith("//")) {
|
if (line.text.startsWith("//")) {
|
||||||
backingLines[i].annotations.add(
|
backingLines[i]
|
||||||
LineAnnotation(SourceLink(path, lineStart: backingLines[i].lineNumber, colStart: 0, colEnd: line.text.length + 1, lineEnd: i), "markdown", AnnotationType.highlight, "comment"));
|
.annotations
|
||||||
|
.add(LineAnnotation(SourceLink(path, lineStart: backingLines[i].lineNumber, colStart: 0, colEnd: line.text.length + 1, lineEnd: i), "markdown", AnnotationType.highlight, "comment"));
|
||||||
|
|
||||||
if (line.text.contains("TODO")) {
|
if (line.text.contains("TODO")) {
|
||||||
backingLines[i].annotations.add(
|
backingLines[i]
|
||||||
LineAnnotation(SourceLink(path, lineStart: backingLines[i].lineNumber, colStart: 0, colEnd: line.text.length + 1, lineEnd: i), "markdown", AnnotationType.todo, "todo"));
|
.annotations
|
||||||
|
.add(LineAnnotation(SourceLink(path, lineStart: backingLines[i].lineNumber, colStart: 0, colEnd: line.text.length + 1, lineEnd: i), "markdown", AnnotationType.todo, "todo"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (line.text.startsWith("#")) {
|
if (line.text.startsWith("#")) {
|
||||||
// this is a header
|
// this is a header
|
||||||
backingLines[i].annotations.add(
|
backingLines[i]
|
||||||
LineAnnotation(SourceLink(path, lineStart: backingLines[i].lineNumber, colStart: 0, colEnd: line.text.length + 1, lineEnd: i), "markdown", AnnotationType.highlight, "header"));
|
.annotations
|
||||||
|
.add(LineAnnotation(SourceLink(path, lineStart: backingLines[i].lineNumber, colStart: 0, colEnd: line.text.length + 1, lineEnd: i), "markdown", AnnotationType.highlight, "header"));
|
||||||
|
|
||||||
var level = 0;
|
var level = 0;
|
||||||
for (var lvl = 0; lvl < 6; lvl++) {
|
for (var lvl = 0; lvl < 6; lvl++) {
|
||||||
|
@ -349,18 +286,21 @@ class LineFile extends ChangeNotifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (line.text.startsWith(" ")) {
|
if (line.text.startsWith(" ")) {
|
||||||
backingLines[i].annotations.add(
|
backingLines[i]
|
||||||
LineAnnotation(SourceLink(path, lineStart: backingLines[i].lineNumber, colStart: 0, colEnd: line.text.length + 1, lineEnd: i), "markdown", AnnotationType.highlight, "code"));
|
.annotations
|
||||||
|
.add(LineAnnotation(SourceLink(path, lineStart: backingLines[i].lineNumber, colStart: 0, colEnd: line.text.length + 1, lineEnd: i), "markdown", AnnotationType.highlight, "code"));
|
||||||
}
|
}
|
||||||
|
|
||||||
_boldRegex.allMatches(backingLines[i].text).forEach((match) {
|
_boldRegex.allMatches(backingLines[i].text).forEach((match) {
|
||||||
backingLines[i].annotations.add(
|
backingLines[i]
|
||||||
LineAnnotation(SourceLink(path, lineStart: backingLines[i].lineNumber, colStart: match.start, colEnd: match.end + 1, lineEnd: i), "markdown", AnnotationType.highlight, "bold"));
|
.annotations
|
||||||
|
.add(LineAnnotation(SourceLink(path, lineStart: backingLines[i].lineNumber, colStart: match.start, colEnd: match.end + 1, lineEnd: i), "markdown", AnnotationType.highlight, "bold"));
|
||||||
});
|
});
|
||||||
|
|
||||||
_codeRegex.allMatches(backingLines[i].text).forEach((match) {
|
_codeRegex.allMatches(backingLines[i].text).forEach((match) {
|
||||||
backingLines[i].annotations.add(
|
backingLines[i]
|
||||||
LineAnnotation(SourceLink(path, lineStart: backingLines[i].lineNumber, colStart: match.start, colEnd: match.end + 1, lineEnd: i), "markdown", AnnotationType.highlight, "code"));
|
.annotations
|
||||||
|
.add(LineAnnotation(SourceLink(path, lineStart: backingLines[i].lineNumber, colStart: match.start, colEnd: match.end + 1, lineEnd: i), "markdown", AnnotationType.highlight, "code"));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
@ -405,12 +345,10 @@ class LineFile extends ChangeNotifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
void mouseDownUpdate(int line, int col) {
|
void mouseDownUpdate(int line, int col) {
|
||||||
cancelSuggestions();
|
|
||||||
cursor.mouseDownUpdate(line, col, backingLines);
|
cursor.mouseDownUpdate(line, col, backingLines);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mouseDownMoveUpdate(int col) {
|
void mouseDownMoveUpdate(int col) {
|
||||||
cancelSuggestions();
|
|
||||||
cursor.mouseDownMoveUpdate(col, backingLines);
|
cursor.mouseDownMoveUpdate(col, backingLines);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -449,7 +387,6 @@ class LineFile extends ChangeNotifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
addNote(String note) {
|
addNote(String note) {
|
||||||
|
|
||||||
var notetype = "note";
|
var notetype = "note";
|
||||||
if (note.startsWith("[incomplete]")) {
|
if (note.startsWith("[incomplete]")) {
|
||||||
notetype = "incomplete";
|
notetype = "incomplete";
|
||||||
|
@ -457,16 +394,15 @@ class LineFile extends ChangeNotifier {
|
||||||
notetype = "edit";
|
notetype = "edit";
|
||||||
}
|
}
|
||||||
|
|
||||||
backingLines[cursor.line-1].annotations.add(
|
backingLines[cursor.line - 1].annotations.add(LineAnnotation(
|
||||||
LineAnnotation(
|
SourceLink(
|
||||||
SourceLink(
|
path,
|
||||||
path,
|
lineStart: cursor.line,
|
||||||
lineStart: cursor.line,
|
),
|
||||||
),
|
"notes",
|
||||||
"notes",
|
AnnotationType.note,
|
||||||
AnnotationType.note,
|
notetype,
|
||||||
notetype,
|
description: note));
|
||||||
description: note));
|
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,19 +66,30 @@ class _InputListener extends State<InputListener> {
|
||||||
),
|
),
|
||||||
contentPadding: EdgeInsets.symmetric(vertical: 1.0, horizontal: 5.0),
|
contentPadding: EdgeInsets.symmetric(vertical: 1.0, horizontal: 5.0),
|
||||||
actions: [
|
actions: [
|
||||||
|
ElevatedButton.icon(
|
||||||
ElevatedButton.icon(icon: Icon(Icons.label, color: literal,), onPressed: () {
|
icon: Icon(
|
||||||
controller.text = "[edit]${controller.text}";
|
Icons.label,
|
||||||
callback(controller.text);
|
color: literal,
|
||||||
Navigator.of(context).pop();
|
),
|
||||||
}, label: Text("Edit"),style: ButtonStyle(backgroundColor: MaterialStateProperty.all(tabs), foregroundColor: MaterialStateProperty.all(foreground))),
|
onPressed: () {
|
||||||
|
controller.text = "[edit]${controller.text}";
|
||||||
|
callback(controller.text);
|
||||||
ElevatedButton.icon(icon: Icon(Icons.label, color: constant,), onPressed: () {
|
Navigator.of(context).pop();
|
||||||
controller.text = "[incomplete]${controller.text}";
|
},
|
||||||
callback(controller.text);
|
label: Text("Edit"),
|
||||||
Navigator.of(context).pop();
|
style: ButtonStyle(backgroundColor: MaterialStateProperty.all(tabs), foregroundColor: MaterialStateProperty.all(foreground))),
|
||||||
}, label: Text("Incomplete"),style: ButtonStyle(backgroundColor: MaterialStateProperty.all(tabs), foregroundColor: MaterialStateProperty.all(foreground))),
|
ElevatedButton.icon(
|
||||||
|
icon: Icon(
|
||||||
|
Icons.label,
|
||||||
|
color: constant,
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
controller.text = "[incomplete]${controller.text}";
|
||||||
|
callback(controller.text);
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
label: Text("Incomplete"),
|
||||||
|
style: ButtonStyle(backgroundColor: MaterialStateProperty.all(tabs), foregroundColor: MaterialStateProperty.all(foreground))),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
|
@ -19,7 +19,6 @@ class LineInfo extends ChangeNotifier {
|
||||||
bool lineSelected = false;
|
bool lineSelected = false;
|
||||||
List<LineAnnotation> annotations = List.empty(growable: true);
|
List<LineAnnotation> annotations = List.empty(growable: true);
|
||||||
|
|
||||||
|
|
||||||
LineInfo(this.path, this.lineNumber, this.text);
|
LineInfo(this.path, this.lineNumber, this.text);
|
||||||
|
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
|
|
@ -11,7 +11,6 @@ void main(List<String> args) {
|
||||||
docfile.openFile("./example.md", 0);
|
docfile.openFile("./example.md", 0);
|
||||||
var doc = ChangeNotifierProvider.value(value: docfile);
|
var doc = ChangeNotifierProvider.value(value: docfile);
|
||||||
|
|
||||||
|
|
||||||
runApp(MultiProvider(
|
runApp(MultiProvider(
|
||||||
providers: [doc],
|
providers: [doc],
|
||||||
builder: (context, child) {
|
builder: (context, child) {
|
||||||
|
|
|
@ -20,13 +20,18 @@ class _Outline extends State<Outline> {
|
||||||
child: ReorderableListView.builder(
|
child: ReorderableListView.builder(
|
||||||
header: Padding(
|
header: Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 10.0, horizontal: 10.0),
|
padding: const EdgeInsets.symmetric(vertical: 10.0, horizontal: 10.0),
|
||||||
child: Column(children: [Row(mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, children: [
|
child: Column(children: [
|
||||||
Icon(
|
Row(mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, children: [
|
||||||
Icons.edit,
|
Icon(
|
||||||
color: foreground,
|
Icons.edit,
|
||||||
),
|
color: foreground,
|
||||||
Text("subwrite", style: TextStyle(fontSize: 16.0, color: foreground, fontWeight: FontWeight.bold, fontFamily: "Iosevka"))
|
),
|
||||||
]), Divider(color: foreground,)])),
|
Text("subwrite", style: TextStyle(fontSize: 16.0, color: foreground, fontWeight: FontWeight.bold, fontFamily: "Iosevka"))
|
||||||
|
]),
|
||||||
|
Divider(
|
||||||
|
color: foreground,
|
||||||
|
)
|
||||||
|
])),
|
||||||
footer: Padding(padding: const EdgeInsets.symmetric(vertical: 3.0, horizontal: 10.0), child: Divider(color: foreground, thickness: 4.0)),
|
footer: Padding(padding: const EdgeInsets.symmetric(vertical: 3.0, horizontal: 10.0), child: Divider(color: foreground, thickness: 4.0)),
|
||||||
onReorder: (int oldIndex, int newIndex) {
|
onReorder: (int oldIndex, int newIndex) {
|
||||||
var doc = Provider.of<LineFile>(context, listen: false);
|
var doc = Provider.of<LineFile>(context, listen: false);
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:subwrite/theme.dart';
|
|
||||||
|
|
||||||
class Suggestion {
|
|
||||||
String classType;
|
|
||||||
String name;
|
|
||||||
String typeSignature;
|
|
||||||
int partialLen;
|
|
||||||
|
|
||||||
Suggestion(this.classType, this.name, this.partialLen, this.typeSignature);
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool operator ==(Object other) {
|
|
||||||
return other is Suggestion && hashCode == other.hashCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
int get hashCode => classType.hashCode + name.hashCode + typeSignature.hashCode;
|
|
||||||
|
|
||||||
Widget getWidget() {
|
|
||||||
var color = function;
|
|
||||||
switch (classType) {
|
|
||||||
case "const":
|
|
||||||
color = constant;
|
|
||||||
break;
|
|
||||||
case "var":
|
|
||||||
color = variable;
|
|
||||||
break;
|
|
||||||
case "package":
|
|
||||||
color = keyword;
|
|
||||||
break;
|
|
||||||
case "type":
|
|
||||||
color = header;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
|
|
||||||
RichText(text: TextSpan(text: name, style: TextStyle(color: color, fontFamily: "Iosevka", fontSize: 11.0, fontWeight: FontWeight.bold))),
|
|
||||||
RichText(text: TextSpan(text: typeSignature, style: const TextStyle(fontFamily: "Iosevka", fontSize: 10.0))),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue