diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..eb9d30c --- /dev/null +++ b/.clang-format @@ -0,0 +1,24 @@ +--- +UseTab: Always +TabWidth: 8 +AlignConsecutiveAssignments: + Enabled: true +AlignConsecutiveDeclarations: + Enabled: true +AccessModifierOffset: -4 +NamespaceIndentation: All +IndentWidth: 8 +PointerAlignment: Left +ColumnLimit: 0 +AllowShortIfStatementsOnASingleLine: Always +AllowShortBlocksOnASingleLine: Never +AllowShortFunctionsOnASingleLine: Empty +AllowShortLoopsOnASingleLine: true +BreakBeforeBraces: Custom +BraceWrapping: + AfterCaseLabel: true +SpaceBeforeParens: Never +AlignEscapedNewlines: DontAlign +SortIncludes: false +AllowShortEnumsOnASingleLine: false +#IndentPPDirectives: AfterHash diff --git a/pmake.js b/pmake.js index 657e533..a24f136 100644 --- a/pmake.js +++ b/pmake.js @@ -1,23 +1,23 @@ -function main(){ +function main() { pmake.subdirectory("external/ppr"); pmake.subdirectory("external/stb"); - const IDE = new pmake.ExecutableProject("midas"); - IDE.sources = fs.glob("src/*.c", "src/icon/*.c"); - IDE.includes = ["src", main.milsko + "/include"]; - IDE.libdirs = [main.milsko + "/src", main.milsko + "/lib"]; - IDE.libraries = ["stb", "ppr", "Mw"]; + const IDE = new pmake.ExecutableProject("midas"); + IDE.sources = fs.glob("src/*.c", "src/icon/*.c"); + IDE.includes = [ "src", main.milsko + "/include" ]; + IDE.libdirs = [ main.milsko + "/src", main.milsko + "/lib" ]; + IDE.libraries = [ "stb", "ppr", "Mw" ]; pmake.register(IDE); } main.milsko = "/usr/local"; -(function(){ -opt = new pmake.Option("with-milsko=PATH"); -opt.category = "General"; +(function() { +opt = new pmake.Option("with-milsko=PATH"); +opt.category = "General"; opt.description = "Specify path to milsko"; -opt.action = function(value){ +opt.action = function(value) { main.milsko = value; }; diff --git a/src/gui.c b/src/gui.c index a52df49..fa16ebd 100644 --- a/src/gui.c +++ b/src/gui.c @@ -3,6 +3,8 @@ MwWidget window, menu = NULL, fileview = NULL, editor = NULL, console = NULL; +static MwMenu m_about_midas; + static void image_draw_inject(MwWidget handle) { char version[128]; MwPoint p, p2; @@ -32,13 +34,28 @@ static void image_draw_inject(MwWidget handle) { MwLLFreeColor(c); } +static void menu_handler(MwWidget handle, void* user, void* client) { + if(client == m_about_midas) { + gui_version(); + } +} + static void MWAPI resize(MwWidget handle, void* user, void* client) { int ww = MwGetInteger(window, MwNwidth); int wh = MwGetInteger(window, MwNheight); int x, y, w, h; int padding = 5; - if(menu == NULL) menu = MwCreateWidget(MwMenuClass, "menu", window, 0, 0, 0, 0); + if(menu == NULL) { + MwMenu m; + + menu = MwCreateWidget(MwMenuClass, "menu", window, 0, 0, 0, 0); + + m = MwMenuAdd(menu, NULL, "?Help"); + m_about_midas = MwMenuAdd(menu, m, "About Midas"); + + MwAddUserHandler(menu, MwNmenuHandler, menu_handler, NULL); + } ww -= padding * 2; wh -= MwGetInteger(menu, MwNheight) + padding * 2; @@ -126,13 +143,11 @@ void gui_init(void) { MwNheight, h, NULL); - MwTimeSleep(50); + resize(window, NULL, NULL); MwAddUserHandler(window, MwNresizeHandler, resize, NULL); - resize(window, NULL, NULL); - - gui_version(); + MwTimeSleep(50); } static void version_ok_activate(MwWidget handle, void* user, void* client) {