Compare commits
3 Commits
46d758c191
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3e6d3cc839 | ||
|
|
1e70444992 | ||
|
|
e40d8773c4 |
@@ -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);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#if PLUGIN_BASIC_COMMANDS
|
||||
void CMD_Redo() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
RedoEdit(active.buffer, &active.view->carets);
|
||||
@@ -271,3 +272,4 @@ void CMD_PlayMacro() {
|
||||
|
||||
For (MacroPlayback) Add(&EventPlayback, it);
|
||||
} RegisterCommand(CMD_PlayMacro, "alt-m", "Start playing back a macro recording");
|
||||
#endif
|
||||
@@ -1,3 +1,4 @@
|
||||
#if PLUGIN_BUILD_WINDOW
|
||||
WindowID BuildWindowID;
|
||||
ViewID BuildViewID;
|
||||
BufferID BuildBufferID;
|
||||
@@ -90,3 +91,4 @@ void CMD_ShowBuildWindow() {
|
||||
main.window->visible = false;
|
||||
}
|
||||
} RegisterCommand(CMD_ShowBuildWindow, "ctrl-grave", "Toggles visibility of the build window");
|
||||
#endif
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#if PLUGIN_COMMAND_RUNNER_WINDOW
|
||||
WindowID CommandRunnerWindowID;
|
||||
|
||||
void CMD_ShowCommandRunner() {
|
||||
@@ -65,3 +66,4 @@ void InitCommandRunnerWindow() {
|
||||
window->jump_history = false;
|
||||
AddCommand(&view->commands, "Open", OpenKeySet, CMD_OpenForRunnerWindow);
|
||||
}
|
||||
#endif // PLUGIN_COMMAND_RUNNER_WINDOW
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#if PLUGIN_COMMAND_WINDOW
|
||||
WindowID CommandWindowID;
|
||||
|
||||
void CMD_ShowCommands() {
|
||||
@@ -84,3 +85,4 @@ void InitCommandWindow() {
|
||||
window->lose_focus_on_escape = true;
|
||||
window->jump_history = false;
|
||||
}
|
||||
#endif // PLUGIN_COMMAND_WINDOW
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#if PLUGIN_DEBUG_WINDOW
|
||||
WindowID DebugWindowID;
|
||||
ViewID DebugViewID;
|
||||
BufferID DebugBufferID;
|
||||
@@ -65,3 +66,4 @@ void CMD_ToggleDebug() {
|
||||
Window *window = GetWindow(DebugWindowID);
|
||||
window->visible = !window->visible;
|
||||
} RegisterCommand(CMD_ToggleDebug, "ctrl-0", "Open a floating window that might become useful for debugging");
|
||||
#endif // PLUGIN_DEBUG_WINDOW
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#if PLUGIN_DIRECTORY_NAVIGATION
|
||||
// @todo: On save rename files, delete files it should apply the changes
|
||||
// Instead of toying with Reopen maybe it should actually detect changes in directory etc. on update
|
||||
|
||||
@@ -204,3 +205,4 @@ void DestroyDirectoryWatcher(DirectoryWatcher *w)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,3 +1,4 @@
|
||||
#if PLUGIN_PROJECT_MANAGEMENT
|
||||
void SetProjectFolder(String dir) {
|
||||
ProjectFolder = Intern(&GlobalInternTable, dir);
|
||||
Scratch scratch;
|
||||
@@ -135,3 +136,4 @@ void CO_CreateProject(mco_coro *co) {
|
||||
|
||||
CO_OpenCode(co);
|
||||
} RegisterCoroutineCommand(CO_CreateProject, "", "Creates a project in current buffer directory with template files and all that, asks user for input etc.");
|
||||
#endif
|
||||
@@ -1 +1,3 @@
|
||||
#if PLUGIN_PROJECT_MANAGEMENT
|
||||
void SetProjectFolder(String name);
|
||||
#endif
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#if PLUGIN_RECORD_EVENTS
|
||||
Buffer *EventBuffer;
|
||||
|
||||
void Serialize(Buffer *buffer, String name, EventKind *kind) {
|
||||
@@ -68,3 +69,4 @@ void Serialize(Buffer *buffer, Event *e) {
|
||||
void CMD_CopyEvents() {
|
||||
SaveStringInClipboard(GetString(EventBuffer));
|
||||
} RegisterCommand(CMD_CopyEvents, "ctrl-shift-alt-j", "Copy all the events from the EventBuffer");
|
||||
#endif
|
||||
@@ -1 +1,3 @@
|
||||
#if PLUGIN_RECORD_GC
|
||||
Buffer *GCInfoBuffer;
|
||||
#endif
|
||||
@@ -1,3 +1,4 @@
|
||||
#if PLUGIN_SEARCH_OPEN_BUFFERS
|
||||
struct SearchOpenBuffersParams {
|
||||
String16 needle;
|
||||
BufferID buffer;
|
||||
@@ -127,3 +128,4 @@ void CMD_SearchOpenBuffers() {
|
||||
}
|
||||
SelectRange(main.view, GetLineRangeWithoutNL(main.buffer, 0));
|
||||
} RegisterCommand(CMD_SearchOpenBuffers, "ctrl-shift-f", "Interactive search over the entire project in a new buffer view");
|
||||
#endif
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#if PLUGIN_SEARCH_WINDOW
|
||||
Int SearchBufferChangeID;
|
||||
|
||||
void CMD_Search() {
|
||||
@@ -110,3 +111,4 @@ void UpdateSearchWindow() {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#if PLUGIN_STATUS_WINDOW
|
||||
WindowID StatusWindowID;
|
||||
|
||||
void InitStatusWindow() {
|
||||
@@ -97,3 +98,4 @@ void UpdateStatusWindow() {
|
||||
SelectRange(title.view, MakeRange(0));
|
||||
ResetHistory(title.buffer);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#if PLUGIN_TESTS
|
||||
|
||||
|
||||
void Wait(mco_coro *co) {
|
||||
{Event ev = {};ev.kind = EVENT_KIND_INVALID; Add(&EventPlayback, ev);}
|
||||
Event *event = NULL;
|
||||
@@ -120,4 +119,4 @@ Memes and stuff)FOO";
|
||||
} RegisterCoroutineCommand(CO_RunTests, "", "Basic tests");
|
||||
|
||||
|
||||
#endif
|
||||
#endif // PLUGIN_TESTS
|
||||
|
||||
118
src/plugin_tutorial.cpp
Normal file
118
src/plugin_tutorial.cpp
Normal 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
|
||||
@@ -1,3 +1,4 @@
|
||||
#if PLUGIN_WINDOW_MANAGEMENT
|
||||
void CMD_JumpPrev() {
|
||||
BSet main = GetBSet(PrimaryWindowID);
|
||||
JumpToLastValidView(main.window);
|
||||
@@ -80,3 +81,4 @@ void CMD_GotoPrevInList() {
|
||||
BSet main = GetBSet(PrimaryWindowID);
|
||||
GotoNextInList(main.window, -1);
|
||||
} RegisterCommand(CMD_GotoPrevInList, "alt-e | shift-f8", "For example: when jumping from build panel to build error, a jump point is setup, user can click this button to go over to the previous compiler error");
|
||||
#endif
|
||||
|
||||
@@ -73,8 +73,7 @@
|
||||
#include "render_opengl.cpp"
|
||||
|
||||
#define PLUGIN_CONFIG 1
|
||||
#define PLUGIN_SEARCH_WINDOW 1
|
||||
#define PLUGIN_PROJECT_MANAGEMENT 1
|
||||
#define PLUGIN_TUTORIAL 1
|
||||
#define PLUGIN_WINDOW_MANAGEMENT 1
|
||||
#define PLUGIN_DIRECTORY_NAVIGATION 1
|
||||
#define PLUGIN_SEARCH_OPEN_BUFFERS 1
|
||||
@@ -88,7 +87,6 @@
|
||||
#define PLUGIN_DEBUG_WINDOW 1
|
||||
#define PLUGIN_RECORD_GC 1
|
||||
#define PLUGIN_RECORD_EVENTS 1
|
||||
#define PLUGIN_DIRECTORY_NAVIGATION 1
|
||||
#define PLUGIN_LOAD_VCVARS OS_WINDOWS
|
||||
#define PLUGIN_REMEDYBG OS_WINDOWS
|
||||
#define PLUGIN_FILE_COMMANDS 1
|
||||
@@ -135,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), {
|
||||
@@ -987,6 +986,7 @@ int main(int argc, char **argv, char **envp)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if PLUGIN_TESTS
|
||||
if (1) {
|
||||
RunArenaTest();
|
||||
For (TestFunctions) {
|
||||
@@ -996,6 +996,7 @@ int main(int argc, char **argv, char **envp)
|
||||
// ReportErrorf("Testing DONE\n");
|
||||
// return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!SDL_Init(SDL_INIT_VIDEO)) {
|
||||
ReportErrorf("Couldn't initialize SDL! %s", SDL_GetError());
|
||||
@@ -1028,6 +1029,7 @@ int main(int argc, char **argv, char **envp)
|
||||
int hhalf = 1000;
|
||||
int xhalf = 100;
|
||||
int yhalf = 100;
|
||||
Unused(xhalf); Unused(yhalf);
|
||||
#else
|
||||
SDL_DisplayID primary_display_id = SDL_GetPrimaryDisplay();
|
||||
const SDL_DisplayMode *display_mode = SDL_GetCurrentDisplayMode(primary_display_id);
|
||||
@@ -1043,7 +1045,9 @@ int main(int argc, char **argv, char **envp)
|
||||
ReportErrorf("Couldn't create window! %s", SDL_GetError());
|
||||
return 1;
|
||||
}
|
||||
#if !OS_LINUX
|
||||
SDL_SetWindowPosition(SDLWindow, xhalf, yhalf);
|
||||
#endif
|
||||
|
||||
SDL_WindowGLContext = SDL_GL_CreateContext(SDLWindow);
|
||||
SDL_GL_MakeCurrent(SDLWindow, SDL_WindowGLContext);
|
||||
@@ -1065,10 +1069,12 @@ int main(int argc, char **argv, char **envp)
|
||||
SDL_StartTextInput(SDLWindow);
|
||||
SDL_SetEventEnabled(SDL_EVENT_DROP_FILE, true);
|
||||
SDL_GL_SetSwapInterval(1); // vsync
|
||||
|
||||
{
|
||||
float scale = SDL_GetWindowDisplayScale(SDLWindow);
|
||||
if (scale != 1.0f) DPIScale = scale;
|
||||
}
|
||||
SDL_SyncWindow(SDLWindow);
|
||||
|
||||
// InitBuffers
|
||||
{
|
||||
@@ -1137,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
|
||||
|
||||
Reference in New Issue
Block a user