Compare commits

..

No commits in common. "eeb6744947832ec86b4a702d9050966bbb1ca0bf" and "9fae27601148834b056d24d0bf0278f9cd27a82a" have entirely different histories.

View File

@ -7,9 +7,6 @@ const SERVER_STATUS_TEXT: Dictionary = {
const ACCEPTED_FILE_FORMATS := ["md"] # server should ignore these file types when adding endpoints const ACCEPTED_FILE_FORMATS := ["md"] # server should ignore these file types when adding endpoints
export(bool) var enable_file_autosave := true # if true, will save the active file's contents every save_file_timeout seconds.
export(float) var save_file_timeout := 4.0 # the time to save document content after the edited signal of TextEdit
enum ContextMenuOptions { enum ContextMenuOptions {
MOVE_UP, MOVE_UP,
MOVE_DOWN, MOVE_DOWN,
@ -150,7 +147,7 @@ func set_server_running(running: bool) -> void:
is_server_running = running # TODO: logic for disabling and enabling certain nodes is_server_running = running # TODO: logic for disabling and enabling certain nodes
func _generate_filestxt(): func _generate_filestxt() -> String:
var files := "" var files := ""
for file in working_files: for file in working_files:
@ -158,12 +155,7 @@ func _generate_filestxt():
if file.include_in_filestxt: if file.include_in_filestxt:
files += "%s %s %s\n" % [file.file_path, file.date, file.title] files += "%s %s %s\n" % [file.file_path, file.date, file.title]
var f := File.new() return files
if f.open(server_dir.plus_file("files.txt"), File.WRITE) == OK:
f.store_string(files)
f.close()
else:
push_error("File.txt open for save error!")
func _is_file_in_filestxt(path: String) -> bool: func _is_file_in_filestxt(path: String) -> bool:
@ -237,26 +229,6 @@ func _on_DocInputTextEdit_text_changed() -> void:
current_file.content = new_text current_file.content = new_text
current_file.dirty = true current_file.dirty = true
if !current_file.timer:
var t := Timer.new()
t.wait_time = save_file_timeout
t.one_shot = true
current_file.timer = t
add_child(t)
t.connect("timeout", self, "_on_EditedTimeout_timeout", [t, current_file])
else:
current_file.timer.stop()
current_file.timer.start()
func _on_EditedTimeout_timeout(timer: Timer, file: FileDef) -> void:
file.timer = null
timer.queue_free()
var f := File.new()
if f.open(server_dir.plus_file(file.file_path), File.WRITE) == OK:
f.store_string(file.content)
func FileDef( func FileDef(
file_path: String, file_path: String,
@ -280,5 +252,3 @@ class FileDef:
var dirty: bool = false var dirty: bool = false
var content: String var content: String
var timer: Timer