(wip) advanced langtons ant
(wip) advanced langtons ant
This commit is contained in:
16
langtons-ant/addons/godot_vim/commands/find.gd
Normal file
16
langtons-ant/addons/godot_vim/commands/find.gd
Normal file
@@ -0,0 +1,16 @@
|
||||
const Constants = preload("res://addons/godot_vim/constants.gd")
|
||||
const Mode = Constants.Mode
|
||||
|
||||
func execute(api : Dictionary, args: String):
|
||||
api.command_line.search_pattern = args.substr(1)
|
||||
var rmatch: RegExMatch = api.vim_plugin.search_regex(
|
||||
api.code_edit,
|
||||
api.command_line.search_pattern,
|
||||
api.cursor.get_caret_pos() + Vector2i.RIGHT
|
||||
)
|
||||
if rmatch != null:
|
||||
var pos: Vector2i = api.vim_plugin.idx_to_pos(api.code_edit, rmatch.get_start())
|
||||
api.cursor.set_caret_pos(pos.y, pos.x)
|
||||
else:
|
||||
api.status_bar.display_error('Pattern not found: "%s"' % [api.command_line.search_pattern])
|
||||
api.cursor.set_mode(Mode.NORMAL)
|
||||
1
langtons-ant/addons/godot_vim/commands/find.gd.uid
Normal file
1
langtons-ant/addons/godot_vim/commands/find.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dp7ck72w5b66n
|
||||
6
langtons-ant/addons/godot_vim/commands/goto.gd
Normal file
6
langtons-ant/addons/godot_vim/commands/goto.gd
Normal file
@@ -0,0 +1,6 @@
|
||||
const Constants = preload("res://addons/godot_vim/constants.gd")
|
||||
const Mode = Constants.Mode
|
||||
|
||||
func execute(api, args):
|
||||
api.cursor.set_caret_pos(args.to_int(), 0)
|
||||
api.cursor.set_mode(Mode.NORMAL)
|
||||
1
langtons-ant/addons/godot_vim/commands/goto.gd.uid
Normal file
1
langtons-ant/addons/godot_vim/commands/goto.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cu4md7kr2qrp
|
||||
29
langtons-ant/addons/godot_vim/commands/marks.gd
Normal file
29
langtons-ant/addons/godot_vim/commands/marks.gd
Normal file
@@ -0,0 +1,29 @@
|
||||
const Contants = preload("res://addons/godot_vim/constants.gd")
|
||||
const StatusBar = preload("res://addons/godot_vim/status_bar.gd")
|
||||
const Mode = Contants.Mode
|
||||
|
||||
func execute(api, _args):
|
||||
var marks: Dictionary = api.get('marks', {})
|
||||
if marks.is_empty():
|
||||
api.status_bar.display_error("No marks set")
|
||||
api.cursor.set_mode(Mode.NORMAL)
|
||||
return
|
||||
|
||||
var display_mark = func(key: String, m: Dictionary) -> String:
|
||||
var pos: Vector2i = m.get('pos', Vector2i())
|
||||
var file: String = m.get('file', '')
|
||||
return "\n%s\t\t%s \t%s \t\t %s" % [key, pos.y, pos.x, file]
|
||||
|
||||
var text: String = "[color=%s]List of all marks[/color]\nmark\tline\tcol \t file" % StatusBar.SPECIAL_COLOR
|
||||
for key in marks.keys():
|
||||
var unicode: int = key.unicode_at(0)
|
||||
if (unicode < 65 or unicode > 90) and (unicode < 97 or unicode > 122):
|
||||
continue
|
||||
text += display_mark.call(key, marks[key])
|
||||
for key in marks.keys():
|
||||
var unicode: int = key.unicode_at(0)
|
||||
if (unicode >= 65 and unicode <= 90) or (unicode >= 97 and unicode <= 122) or key == "-1":
|
||||
continue
|
||||
text += display_mark.call(key, marks[key])
|
||||
|
||||
api.status_bar.display_text(text, Control.TEXT_DIRECTION_LTR)
|
||||
1
langtons-ant/addons/godot_vim/commands/marks.gd.uid
Normal file
1
langtons-ant/addons/godot_vim/commands/marks.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cf1an2q01i3ix
|
||||
Reference in New Issue
Block a user