From 49e859c0d2bf41fa648e0da45a6d5b114b0d2240 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Tue, 9 Aug 2022 21:51:58 +0200 Subject: Add eb.el. Emacs is not a great IDE out-of-the-box, but it is very flexible -- and in many ways a lot more transparent than most normal IDEs. --- Makefile | 2 +- c/main.cpp | 16 +++++++++++++--- eb.el | 27 +++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 eb.el diff --git a/Makefile b/Makefile index 87a055d..9873d7a 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ CLFLAGS = -DUNICODE -D_UNICODE CLFLAGS += -cc-options,-std=c++17 -O2 CLFLAGS += -Wall -Wextra -Wpedantic -Wno-missing-field-initializers -Wno-parentheses CLFLAGS += -ld-options,-mwindows,-static-libstdc++ -lcomctl32 -#CLFLAGS += -ld-options,-mconsole +CLFLAGS += -DDEBUG all: showdeps b/$(EXE) cp b/$(EXE) "C:\Users\John\Desktop\Delat" diff --git a/c/main.cpp b/c/main.cpp index e51e0f9..60504b2 100644 --- a/c/main.cpp +++ b/c/main.cpp @@ -12,6 +12,14 @@ #include "pl.h" #include "util.h" +#ifdef DEBUG +#define XMAIN 30 +#define YMAIN 30 +#else +#define XMAIN CW_USEDEFAULT +#define YMAIN CW_USEDEFAULT +#endif + /* main.cpp defines all global (non-template) variables used in the * program. `extern' is used to access them from other files, when * need be. */ @@ -96,12 +104,14 @@ static void OnTerminate() noexcept int WINAPI WinMain(const HINSTANCE hInstance, const HINSTANCE, char* const, const int nCmdShow) { + setbuf(stdout, nullptr); + /* Exit gracefully on uncaught exception. */ std::set_terminate(OnTerminate); /* Initialize Prolog. */ - char* argv[] = {const_cast("EpisodeBrowser"), nullptr}; - if (!PL_initialise(1, argv)) + const char* argv[] = {"EpisodeBrowser", nullptr}; + if (!PL_initialise(1, const_cast(argv))) throw std::runtime_error("Could not initialize Prolog."); if (!Pl("track_episodes","attach") || !Pl("episode_data","attach")) throw std::runtime_error("Could not attach databases."); @@ -137,7 +147,7 @@ int WINAPI WinMain(const HINSTANCE hInstance, const HINSTANCE, char* const, cons L"Episode Browser", L"Episode Browser", WS_OVERLAPPEDWINDOW|WS_CLIPCHILDREN, - CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, + XMAIN, YMAIN, 0, 0, nullptr, nullptr, hInstance, nullptr)); g_hWndStatus = Require(CreateWindowEx( diff --git a/eb.el b/eb.el new file mode 100644 index 0000000..594c4e3 --- /dev/null +++ b/eb.el @@ -0,0 +1,27 @@ +;;; eb --- Episode Browser development functions for Emacs + +;;; Commentary: + +;;; Code: + +(defcustom eb-cwd "b" + "Working directory for executable." + :group 'eb + :type 'directory) + +;;;###autoload +(defun eb-run () + "Launch built executable, displaying its output in a buffer." + (interactive) + (require 'project) + (let ((buf (get-buffer-create "*eb-run*")) + (exe (concat (project-root (project-current)) + "/b/EpisodeBrowser.exe")) + (default-directory eb-cwd)) + (with-current-buffer buf + (compilation-mode)) + (start-process "EpisodeBrowser" buf exe) + (display-buffer buf))) + +(provide 'eb) +;;; eb.el ends here -- cgit v1.2.3