Fix opening things in file browser, fix [code] highlighting

This commit is contained in:
Sebastian Morr 2020-10-06 10:38:31 +02:00
parent f3ff5c5147
commit 8c4c4feeef
12 changed files with 29 additions and 100 deletions

View file

@ -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):

View file

@ -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:

View file

@ -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

View file

@ -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^)"

View file

@ -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")

View file

@ -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]

View file

@ -1 +1,3 @@
sandbox
motivation
setup
restore

View file

@ -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):

View file

@ -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);

View file

@ -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")

View file

@ -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"]

View file

@ -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():