Plugin tutorial init:

This commit is contained in:
KK
2026-07-04 11:45:17 +02:00
parent 1e70444992
commit 3e6d3cc839
3 changed files with 127 additions and 1 deletions

View File

@@ -172,7 +172,7 @@ RegisterVariable(Int, WaitForEvents, 1);
RegisterVariable(Int, DrawLineNumbers, 1);
RegisterVariable(Int, DrawScrollbar, 1);
RegisterVariable(Int, IndentSize, 4);
RegisterVariable(Int, FontSize, 15);
RegisterVariable(Int, FontSize, 20);
RegisterVariable(String, PathToFont, "");
RegisterVariable(Float, UndoMergeTime, 0.3);
RegisterVariable(Float, JumpHistoryMergeTime, 0.3);

118
src/plugin_tutorial.cpp Normal file
View File

@@ -0,0 +1,118 @@
#if PLUGIN_TUTORIAL
#define RegisterTutorialSection(NAME, DESC, STRING)\
String NAME##_string = STRING;\
void CMD_##NAME() {\
Buffer *buffer = CreateBuffer(SysAllocator, GetUniqueBufferName(ProjectFolder, #NAME), NAME##_string.len * 4 + 4096);\
buffer->temp = true;\
RawAppend(buffer, NAME##_string);\
buffer->dirty = false;\
Open(buffer->name);\
} RegisterCommand(CMD_##NAME, "", DESC);
RegisterTutorialSection(EnterTheTutorial, "The guide to sailing the text", R"==(
Hello sailor!
--------------------------------
I see you have entered the unknown
text waters of the internet.
Before we set sail, right click:
:CoolText
...and watch the waters stir.
)==");
RegisterTutorialSection(CoolText, "Coolest text inside the coolest tutorial", R"==(
The text can lead you
into interesting places
--------------------------------
Do not be afraid. Try these too:
:MakeFontLarger
:MakeFontSmaller
Make the letters huge.
Then make them tiny again.
and then ...
--------------------------------
:GoToNextSectionOfTheTutorial!
)==");
RegisterTutorialSection(GoToNextSectionOfTheTutorial, "Yes!", R"==(
Special words listen to keys too:
Ctrl-+ Ctrl--
Even right click has a twin:
Ctrl-Q F12
Put your caret here and try:
:Prev
:New (beware, you may never return! Hint: Take a look at the bar on the bottom)
:HowToFindCommands
)==");
RegisterTutorialSection(HowToFindCommands, "Tutorial on finding the commands", R"==(
Open the map:
:ShowCommands (Ctrl-Shift-P)
Type a few letters.
Press (Enter) to choose.
These special words are not magical
You can easily find them
and use.
-------------------------------
HowToBindCommandsToKeys
-------------------------------
)==");
RegisterTutorialSection(HowToBindCommandsToKeys, "how to bind commands to keys", R"==(
We will start easy. Try selecting the entire line below and (ctrl-q / right click / F12)
:Set DrawLineNumbers 0
:Set TextColor ffaa0000
Make it normal again:
:Set DrawLineNumbers 1
:Set TextColor ff21201d
And of course this setup also works for keys:
:Set MakeFontLarger 'ctrl-t'
See the map for this:
:OpenConfigOptions
)==");
void InitTutorial() {
CMD_EnterTheTutorial();
}
#endif

View File

@@ -73,6 +73,7 @@
#include "render_opengl.cpp"
#define PLUGIN_CONFIG 1
#define PLUGIN_TUTORIAL 1
#define PLUGIN_WINDOW_MANAGEMENT 1
#define PLUGIN_DIRECTORY_NAVIGATION 1
#define PLUGIN_SEARCH_OPEN_BUFFERS 1
@@ -132,6 +133,7 @@
#include "plugin_file_commands.cpp"
#include "plugin_word_complete.cpp"
#include "plugin_tests.cpp"
#include "plugin_tutorial.cpp"
#if OS_WASM
EM_JS(void, JS_SetMouseCursor, (const char *cursor_str), {
@@ -1141,6 +1143,12 @@ int main(int argc, char **argv, char **envp)
Open(argv[i]);
}
#if PLUGIN_TUTORIAL
if (argc == 1) {
InitTutorial();
}
#endif
#if PLUGIN_LOAD_VCVARS
LoadVCVars();
#endif