diff --git a/file_browser.gd b/file_browser.gd index d49463c..cbef3c4 100644 --- a/file_browser.gd +++ b/file_browser.gd @@ -27,7 +27,7 @@ func update(): func _on_item_selected(): var item = $FileTree.get_selected() var file_path = item.get_text(0) - + shell.run("%s/fake-editor-noblock %s" % [game.tmp_prefix_inside, file_path]) func very_best_sort(a,b): diff --git a/level.gd b/level.gd index 15ab2d2..a65b660 100644 --- a/level.gd +++ b/level.gd @@ -66,8 +66,9 @@ func load(path): # Surround all lines indented with four spaces with [code] tags. var monospace_regex = RegEx.new() - monospace_regex.compile("\n (.*)\n") - description = monospace_regex.sub(description, "\n [code]$1[/code]\n", true) + monospace_regex.compile("\\n ([^\\n]*)") + description = monospace_regex.sub(description, "\n [code]$1[/code]", true) + print(description) func construct(): for r in repos: diff --git a/levels/intro/commit b/levels/intro/commit deleted file mode 100644 index cb18e51..0000000 --- a/levels/intro/commit +++ /dev/null @@ -1,28 +0,0 @@ -title = "fu" - -[description] - -So you've been working on a project for a while, and decide you want to put it in a Git repository. - -Here's how to do it! First, you initialize a new Git repository in your current directory: - - git init - -Then say that you want to record the current state of all files: - - git add . - -And then you make a commit, which gives the current state a description, a date, and your name: - - git commit - -[setup] - -mkdir recipes -echo -e "blueberries\nflour" > recipes/blueberry_cake.txt -echo -e "water\ncarrots" > recipes/carrot soup.txt -echo "Very good recipes!" > README.md - -[win] - -test "$(git rev-parse HEAD^{tree})" = 1e02e3151284d0e22cd9b07ca5c5dbae2f3cb521 diff --git a/levels/intro/pull-merge-push b/levels/intro/pull-merge-push deleted file mode 100644 index 1e64ffc..0000000 --- a/levels/intro/pull-merge-push +++ /dev/null @@ -1,32 +0,0 @@ -title = A pull and a conflict -author = blinry - -[description] - -You want to push your new commits to the server, but someone has already pushed their own changes. - -In this situation, you need to pull first! Try that here - you'll have to resolve a merge conflict. Push your changes afterwards. - -[congrats] - -Good job! Here's some additional info: banana! - -[setup yours] - -echo fu > file -git add . -git commit -m "Initial commit" -git push - -echo fi > file -git commit -a -m "Fi is good" - -[setup origin] - -echo fa > file -git add . -git commit -a -m "Fa is good" - -[win origin] - -test "$(git rev-parse HEAD^1^)" = "$(git rev-parse HEAD^2^)" diff --git a/levels/intro/rebase b/levels/intro/rebase deleted file mode 100644 index 9a46e7f..0000000 --- a/levels/intro/rebase +++ /dev/null @@ -1,20 +0,0 @@ -description = Rebase all branches on top of the main branch, so that the commits are in alphabetical order, and then point the main branch to the top commit. - -[setup] - -git commit --allow-empty -m A -git commit --allow-empty -m B -git commit --allow-empty -m C - -git switch -c side1 main~1 -git commit --allow-empty -m D -git commit --allow-empty -m E - -git switch -c side2 main~2 -git commit --allow-empty -m F - -git checkout main - -[win] - -diff <(git log --pretty=%s main) <(echo -e "F\nE\nD\nC\nB\nA") diff --git a/levels/intro/sandbox b/levels/intro/sandbox deleted file mode 100644 index c6396c5..0000000 --- a/levels/intro/sandbox +++ /dev/null @@ -1,8 +0,0 @@ -[setup local] - -git commit --allow-empty -m "1" -git commit --allow-empty -m "2" -git commit --allow-empty -m "3" -git push - -[setup origin] diff --git a/levels/intro/sequence b/levels/intro/sequence index b04600a..6c6c634 100644 --- a/levels/intro/sequence +++ b/levels/intro/sequence @@ -1 +1,3 @@ -sandbox +motivation +setup +restore diff --git a/main.gd b/main.gd index eef6891..64393aa 100644 --- a/main.gd +++ b/main.gd @@ -26,21 +26,21 @@ func _ready(): helpers.crash("Could not change to sandbox scene") return - current_chapter = 0 + current_chapter = 2 current_level = 0 # Initialize level select. level_select.connect("item_selected", self, "load_level") repopulate_levels() - level_select.select(0) + level_select.select(current_level) # Initialize chapter select. chapter_select.connect("item_selected", self, "load_chapter") repopulate_chapters() - chapter_select.select(0) + chapter_select.select(current_chapter) # Load first chapter. - load_chapter(0) + load_chapter(current_chapter) input.grab_focus() func load_chapter(id): diff --git a/scripts/fake-editor-noblock b/scripts/fake-editor-noblock index 76eef3d..4f1fec4 100755 --- a/scripts/fake-editor-noblock +++ b/scripts/fake-editor-noblock @@ -1,14 +1,16 @@ #!/usr/bin/env perl use IO::Socket; +use File::Spec; $socket = IO::Socket::INET->new(PeerAddr => "127.0.0.1", PeerPort => 1234, Proto => "tcp", Type => SOCK_STREAM); -# Send the length of the first argument as a byte. -$socket->send(chr(length($ARGV[0]))); -# Send the first argument as a string. -$socket->send($ARGV[0]); +my $absolute_path = File::Spec->rel2abs($ARGV[0]); +# Send the length of string as a byte. +$socket->send(chr(length($absolute_path))); +# Send the first argument as a string. +$socket->send($absolute_path); diff --git a/terminal.gd b/terminal.gd index d2d4d07..aafb5d4 100644 --- a/terminal.gd +++ b/terminal.gd @@ -208,3 +208,6 @@ func _completion_selected(): #completions.hide() input.grab_focus() input.caret_position = input.text.length() + +func editor_saved(): + emit_signal("command_done") diff --git a/terminal.tscn b/terminal.tscn index dbba3f6..3924f3c 100644 --- a/terminal.tscn +++ b/terminal.tscn @@ -131,4 +131,5 @@ __meta__ = { [connection signal="text_changed" from="Rows/InputLine/Input" to="." method="_input_changed"] [connection signal="text_entered" from="Rows/InputLine/Input" to="." method="send_command"] [connection signal="pressed" from="ClearButton" to="." method="clear"] +[connection signal="saved" from="TextEditor" to="." method="editor_saved"] [connection signal="data_received" from="TCPServer" to="." method="receive_output"] diff --git a/text_editor.gd b/text_editor.gd index f3344b0..8bc0b3b 100644 --- a/text_editor.gd +++ b/text_editor.gd @@ -1,5 +1,7 @@ extends TextEdit +signal saved + var path var _server @@ -30,7 +32,13 @@ func open(filename): func save(): var fixme_path = game.tmp_prefix_outside+"repos/" + + # Add a newline to the end of the file if there is none. + if text.length() > 0 and text.substr(text.length()-1, 1) != "\n": + text += "\n" + helpers.write_file(fixme_path+path, text) + emit_signal("saved") close() func close():