Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
# Only include the addons folder when downloading from the Asset Library.
/** export-ignore
/addons !export-ignore
/addons/bbcode_edit.editor !export-ignore
/addons/bbcode_edit.editor/** !export-ignore
/addons/bbcode_edit.editor/.assets_for_readme/*.mp4 export-ignore
/addons/bbcode_edit !export-ignore
/addons/bbcode_edit/** !export-ignore
/addons/bbcode_edit/.assets_for_readme/*.mp4 export-ignore
/addons/any_icon.editor !export-ignore
/addons/any_icon.editor/** !export-ignore
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ in order to help format documentation comments.

There are **shortcuts** to easily toggle some formattings:

![Using the keyboard to toggle bold, italic, underline, striketrough](/addons/bbcode_edit.editor/.assets_for_readme/shortcuts.gif)
![Using the keyboard to toggle bold, italic, underline, striketrough](/.assets_for_readme/shortcuts.gif)


**Completion** for formatting tags, with some special completions implemented for specific tags:

![Advanced completion for color tag](/addons/bbcode_edit.editor/.assets_for_readme/color_completion.gif)
![Advanced completion for color tag](/.assets_for_readme/color_completion.gif)


**Documentation references** are completed:

![Reference completion](/addons/bbcode_edit.editor/.assets_for_readme/reference_completion.gif)
![Reference completion](/.assets_for_readme/reference_completion.gif)


Some useful **snippets** are included:

![A "Note" snippet, with the same formatting as the one used in the official documentation](/addons/bbcode_edit.editor/.assets_for_readme/snippet.gif)
![A "Note" snippet, with the same formatting as the one used in the official documentation](/.assets_for_readme/snippet.gif)


## Features / Roadmap
Expand Down Expand Up @@ -84,17 +84,14 @@ You can download the addon:
- On GitHub: `Code` → `Download ZIP`.
- Through the editor: `AssetLib` → Search for "BBCodeEdit"

*By default, this readme is included, along with it's illustrations. If you don't want them,
do not download `addons/bbcode_edit.editor/README.md` nor `addons/bbcode_edit.editor/.assets_for_readme/*`*

*You can also remove `addons/bbcode_edit.editor/completions_cd/builtin_classes_[godot versions that you don't use].txt`*
*You can remove `addons/bbcode_edit/doc_comment.editor/completions_cd/builtin_classes_[godot versions that you don't use].txt`*

To edit shortcuts:
- *If they don't show up* in the input map GUI: first restart the editor
- modify them in the input map GUI
- **restart** the editor to update the input map.

You can also exclude `*.editor/*` or `bbcode_edit.editor/` from your export presets,
You can also exclude `*.editor/*` or `bbcode_edit/doc_comment.editor/` from your export presets,
because this addon is (for now[^editor_only]) script-editor-only.


Expand Down
21 changes: 21 additions & 0 deletions addons/bbcode_edit/doc_comment.editor/LICENCE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Patou

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,35 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://bpwcspqlqm78h"
path="res://.godot/imported/bbcode_completion_icon.svg-e050b1e9fb923c5a17b0f52532042234.ctex"
path="res://.godot/imported/bbcode_completion_icon.svg-a242f72402b90907e6e67e820acf8aa8.ctex"
metadata={
"has_editor_variant": true,
"vram_texture": false
}

[deps]

source_file="res://addons/bbcode_edit.editor/bbcode_completion_icon.svg"
dest_files=["res://.godot/imported/bbcode_completion_icon.svg-e050b1e9fb923c5a17b0f52532042234.ctex"]
source_file="res://addons/bbcode_edit/doc_comment.editor/bbcode_completion_icon.svg"
dest_files=["res://.godot/imported/bbcode_completion_icon.svg-a242f72402b90907e6e67e820acf8aa8.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,27 @@ enum CompletionKind {
}


const Completions = preload("res://addons/bbcode_edit.editor/completions_db/completions.gd")
const Scraper = preload("res://addons/bbcode_edit.editor/editor_interface_scraper.gd")
const Completions = preload("res://addons/bbcode_edit/doc_comment.editor/completions_db/completions.gd")
const Scraper = preload("res://addons/bbcode_edit/doc_comment.editor/editor_interface_scraper.gd")

## @deprecated: Superseded by Tag Toggler
const ACTION_TOGGLE_BOLD = &"bbcode_edit/toggle_bold"
## @deprecated: Superseded by Tag Toggler
const ACTION_TOGGLE_ITALIC = &"bbcode_edit/toggle_italic"
## @deprecated: Superseded by Tag Toggler
const ACTION_TOGGLE_UNDERLINE = &"bbcode_edit/toggle_underline"
## @deprecated: Superseded by Tag Toggler
const ACTION_TOGGLE_STRIKE = &"bbcode_edit/toggle_strike"

## @deprecated: Superseded by Tag Toggler
const TOGGLING_ACTIONS = {
ACTION_TOGGLE_BOLD: "b",
ACTION_TOGGLE_ITALIC: "i",
ACTION_TOGGLE_UNDERLINE: "u",
ACTION_TOGGLE_STRIKE: "s",
}

const BBCODE_COMPLETION_ICON = preload("res://addons/bbcode_edit.editor/bbcode_completion_icon.svg")
const BBCODE_COMPLETION_ICON = preload("res://addons/bbcode_edit/doc_comment.editor/bbcode_completion_icon.svg")
const COLOR_PICKER_CONTAINER_PATH = ^"_BBCodeEditColorPicker"
const COLOR_PICKER_PATH = ^"_BBCodeEditColorPicker/ColorPicker"

Expand Down Expand Up @@ -664,6 +669,7 @@ func add_enums(enums: PackedStringArray) -> void:
)


## @deprecated: Superseded by bbcode_edit/tag_toggler sub-plugin
func toggle_tag(tag: String) -> void:
var prefix: String = "[" + tag + "]"
var prefix_len: int = prefix.length()
Expand Down Expand Up @@ -770,7 +776,7 @@ func _confirm_code_completion(replace: bool = false) -> void:
match parts[0]:
_COMMAND_COLOR_PICKER:
if not has_node(^"BBCODE_EDIT_COLOR_PICKER"):
add_child(preload("res://addons/bbcode_edit.editor/color_picker.tscn").instantiate())
add_child(preload("res://addons/bbcode_edit/doc_comment.editor/color_picker.tscn").instantiate())
var container: PopupPanel = get_node(COLOR_PICKER_CONTAINER_PATH)
var picker: ColorPicker = get_node(COLOR_PICKER_PATH)

Expand Down Expand Up @@ -866,12 +872,12 @@ func _gui_input(event: InputEvent) -> void:
if event is InputEventKey or event is InputEventMouseButton:
get_node(COLOR_PICKER_CONTAINER_PATH).free()

for action in TOGGLING_ACTIONS:
if is_action(event, action):
toggle_tag(TOGGLING_ACTIONS[action])
#for action in TOGGLING_ACTIONS:
#if is_action(event, action):
#toggle_tag(TOGGLING_ACTIONS[action])


func is_action(event: InputEvent, action: StringName) -> bool:
static func is_action(event: InputEvent, action: StringName) -> bool:
return InputMap.has_action(action) and event.is_action(action, true)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
extends EditorPlugin


const BBCodeEdit: GDScript = preload("res://addons/bbcode_edit.editor/bbcode_edit.gd")
const Completions = preload("res://addons/bbcode_edit.editor/completions_db/completions.gd")
const Scraper = preload("res://addons/bbcode_edit.editor/editor_interface_scraper.gd")
const BBCodeEdit: GDScript = preload("res://addons/bbcode_edit/doc_comment.editor/bbcode_edit.gd")
const Completions = preload("res://addons/bbcode_edit/doc_comment.editor/completions_db/completions.gd")
const Scraper = preload("res://addons/bbcode_edit/doc_comment.editor/editor_interface_scraper.gd")


const ADDON_NAME = "BBCode Editor"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
extends Object


const GodotVersion = preload("res://addons/bbcode_edit.editor/completions_db/godot_version.gd")
const Scraper = preload("res://addons/bbcode_edit.editor/editor_interface_scraper.gd")
const GodotVersion = preload("res://addons/bbcode_edit/doc_comment.editor/completions_db/godot_version.gd")
const Scraper = preload("res://addons/bbcode_edit/doc_comment.editor/editor_interface_scraper.gd")

const _BUILTIN_COMPLETIONS_PATH_BEGINING = "res://addons/bbcode_edit.editor/completions_db/builtin_classes_"
const _BUILTIN_COMPLETIONS_PATH_BEGINING = "res://addons/bbcode_edit/doc_comment.editor/completions_db/builtin_classes_"
const DONT_ASK_TO_FETCH_SETTING_PATH = "addons/bbcode_edit/editor/dont_ask_to_fetch_builtin_classes"

const equivalent_versions: Dictionary = {
Expand Down Expand Up @@ -309,7 +309,7 @@ static func get_class_completions() -> ClassCompletions:


static func fetch_builtin_classes() -> void:
EditorInterface.play_custom_scene("res://addons/bbcode_edit.editor/completions_db/fetch_builtin_classes.tscn")
EditorInterface.play_custom_scene("res://addons/bbcode_edit/doc_comment.editor/completions_db/fetch_builtin_classes.tscn")
while EditorInterface.is_playing_scene():
await EditorInterface.get_base_control().get_tree().create_timer(0.1, true, false, true).timeout

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ extends Node
## This has to be a scene.
## (In an EditorScript, editor specifc classes would polute the result)

const Completions = preload("res://addons/bbcode_edit.editor/completions_db/completions.gd")
const Completions = preload("res://addons/bbcode_edit/doc_comment.editor/completions_db/completions.gd")


func _ready() -> void:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://blcco0wsttyck"]

[ext_resource type="Script" uid="uid://cociwvr6oq38v" path="res://addons/bbcode_edit.editor/completions_db/fetch_builtin_classes.gd" id="1_tk0nj"]
[ext_resource type="Script" uid="uid://cociwvr6oq38v" path="res://addons/bbcode_edit/doc_comment.editor/completions_db/fetch_builtin_classes.gd" id="1_tk0nj"]

[node name="FetchClassDB" type="Node"]
script = ExtResource("1_tk0nj")
7 changes: 7 additions & 0 deletions addons/bbcode_edit/doc_comment.editor/plugin.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[plugin]

name="BBCodeEdit: Documentation comment completion"
description="A Godot addon that brings BBCode completion and QOL tools to the script editor in order to help formatting documentation comments."
author="Patou"
version="1.2.1"
script="bbcode_edit_main.gd"
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[plugin]

name="BBCodeEdit (for script editor)"
name="BBCodeEdit"
description="A Godot addon that brings BBCode completion and QOL tools to the script editor in order to help formatting documentation comments."
author="Patou"
version="1.2.1"
Expand Down
21 changes: 21 additions & 0 deletions addons/bbcode_edit/tag_toggler/LICENCE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Patou

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
7 changes: 7 additions & 0 deletions addons/bbcode_edit/tag_toggler/plugin.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[plugin]

name="BBCodeEdit: Tag Toggler"
description="Allow toggling BBCode tags everywhere."
author="Patou"
version="1.0"
script="tag_toggler_main.gd"
82 changes: 82 additions & 0 deletions addons/bbcode_edit/tag_toggler/tag_toggler.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
extends Object


# TODO make so that if it's surrounded by another tag it works too.
# exemple: [b][i]bold italic[/b][/i] → toggling b when selecting only the text would work.
static func toggle_tag(editor: TextEdit, tag: String) -> void:
var prefix: String = "[" + tag + "]"
var prefix_len: int = prefix.length()
var suffix: String = "[/" + tag + "]"
var suffix_len: int = suffix.length()

var main_selection_from_column: int = editor.get_selection_from_column()
var main_selection_from_line: int = editor.get_selection_from_line()
var main_selection_to_column: int = editor.get_selection_to_column()
var main_selection_to_line: int = editor.get_selection_to_line()
var main_selection_end_line: String = editor.get_line(main_selection_to_line)

if (
main_selection_from_column >= prefix_len
and editor.get_line(main_selection_from_line).substr(
main_selection_from_column - prefix_len,
prefix_len
) == prefix
and main_selection_to_column <= main_selection_end_line.length() - suffix_len
and main_selection_end_line.substr(
main_selection_to_column,
suffix_len
) == suffix
):
editor.begin_complex_operation()
editor.begin_multicaret_edit()

for caret in editor.get_caret_count():
if editor.multicaret_edit_ignore_caret(caret):
continue

var initial_text: String = editor.get_selected_text(caret)
var initial_start_column: int = editor.get_selection_from_column(caret)
var initial_end_column: int = editor.get_selection_to_column(caret)

editor.select(
editor.get_selection_from_line(caret),
initial_start_column - prefix_len,
editor.get_selection_to_line(caret),
initial_end_column + suffix_len,
caret
)
editor.insert_text_at_caret(initial_text, caret)
editor.select(
editor.get_selection_from_line(caret),
initial_start_column - prefix_len,
editor.get_selection_to_line(caret),
initial_end_column - prefix_len,
caret
)

editor.end_multicaret_edit()
editor.end_complex_operation()
return

editor.begin_complex_operation()
editor.begin_multicaret_edit()

for caret in editor.get_caret_count():
if editor.multicaret_edit_ignore_caret(caret):
continue

var initial_start_column: int = editor.get_selection_from_column(caret)
var initial_end_column: int = editor.get_selection_to_column(caret)

editor.insert_text_at_caret(prefix + editor.get_selected_text(caret) + suffix, caret)

editor.select(
editor.get_selection_from_line(caret),
initial_start_column + prefix_len,
editor.get_selection_to_line(caret),
initial_end_column + prefix_len,
caret
)

editor.end_multicaret_edit()
editor.end_complex_operation()
1 change: 1 addition & 0 deletions addons/bbcode_edit/tag_toggler/tag_toggler.gd.uid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
uid://vbfluupq1gbw
Loading