Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
editor_url.hpp
Go to the documentation of this file.
1// editor_url.hpp — Inspector source-jump editor URI configuration.
2//
3// This is the configuration plumbing for which editor URI scheme to use
4// when source-jump opens a file:line in the user's editor. The actual
5// jump action lives in source_jump.hpp; this file deals with the
6// template and its substitution.
7//
8// Common editor URL templates (any of these are valid `editor_url_template`
9// values for `InspectorConfig`):
10//
11// VS Code : "vscode://file/{path}:{line}"
12// Cursor : "cursor://file/{path}:{line}"
13// Zed : "zed://file/{path}:{line}:{col}"
14// Sublime : "sublime://open?url=file://{path}&line={line}"
15// JetBrains : "idea://open?file={path}&line={line}"
16//
17// The substitution helper `format_editor_url` replaces `{path}`, `{line}`,
18// and `{col}` tokens with the supplied values. Tokens not present in the
19// template are silently ignored (so a Cursor template without `{col}` will
20// still render correctly when a column is supplied).
21//
22// The runtime config (`InspectorConfig::editor_url_template`) is overridden
23// by the `PULP_INSPECTOR_EDITOR_URL` environment variable when present, so
24// developers can switch editors per-shell without rebuilding.
25#pragma once
26
27#include <cstdint>
28#include <optional>
29#include <string>
30#include <string_view>
31
32namespace pulp::inspect {
33
42 std::string editor_url_template = "vscode://file/{path}:{line}";
43};
44
53
58std::string format_editor_url(std::string_view tmpl,
59 std::string_view path,
60 int line,
61 std::optional<int> col = std::nullopt);
62
67bool validate_editor_url_template(std::string_view tmpl,
68 std::string* error_out = nullptr);
69
73std::optional<std::string> editor_url_env_override();
74
83
85
87std::string_view editor_url_source_name(EditorUrlSource source);
88
89} // namespace pulp::inspect
@ Default
Definition emoji_segmenter.hpp:42
@ path
Definition scene_node.hpp:93
Definition agent_context.hpp:7
EffectiveEditorUrl effective_editor_url(const InspectorConfig &config)
std::optional< std::string > editor_url_env_override()
Look up the environment override (PULP_INSPECTOR_EDITOR_URL).
bool validate_editor_url_template(std::string_view tmpl, std::string *error_out=nullptr)
Validate a candidate editor URL template.
EditorUrlSource
Source that produced the effective editor URL template — used by Inspector.getEditorUrlTemplate so cl...
Definition editor_url.hpp:48
@ Environment
Overridden by PULP_INSPECTOR_EDITOR_URL.
Definition editor_url.hpp:51
@ Default
Built-in fallback (vscode://file/{path}:{line}).
Definition editor_url.hpp:49
@ Config
Set via InspectorConfig / setEditorUrlTemplate.
Definition editor_url.hpp:50
std::string_view editor_url_source_name(EditorUrlSource source)
Stringify the source enum for protocol responses.
std::string format_editor_url(std::string_view tmpl, std::string_view path, int line, std::optional< int > col=std::nullopt)
Substitute {path}, {line}, and {col} in tmpl with the supplied values.
Compute the effective template and its source given the supplied config.
Definition editor_url.hpp:79
std::string template_str
Definition editor_url.hpp:80
EditorUrlSource source
Definition editor_url.hpp:81
Inspector runtime configuration.
Definition editor_url.hpp:38
std::string editor_url_template
URL template used to open a source file in the user's editor.
Definition editor_url.hpp:42