{"id":16445619,"url":"https://github.com/okbob/ncurses-st-menu","last_synced_at":"2025-04-09T18:19:23.646Z","repository":{"id":41947474,"uuid":"128755485","full_name":"okbob/ncurses-st-menu","owner":"okbob","description":"ncurses (pdcurses) based library for CUA look menu","archived":false,"fork":false,"pushed_at":"2024-12-30T06:12:34.000Z","size":4310,"stargazers_count":63,"open_issues_count":0,"forks_count":10,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-09T18:19:16.137Z","etag":null,"topics":["c","cua","menu","menubar","menus","ncurses","ncurses-library","pdcurses","styled-components","tui"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/okbob.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-04-09T10:35:43.000Z","updated_at":"2025-01-18T21:12:53.000Z","dependencies_parsed_at":"2025-02-18T22:10:39.556Z","dependency_job_id":"0cadcc4b-774d-4175-8022-9c2d51202e1c","html_url":"https://github.com/okbob/ncurses-st-menu","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/okbob%2Fncurses-st-menu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/okbob%2Fncurses-st-menu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/okbob%2Fncurses-st-menu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/okbob%2Fncurses-st-menu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/okbob","download_url":"https://codeload.github.com/okbob/ncurses-st-menu/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248085325,"owners_count":21045139,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","cua","menu","menubar","menus","ncurses","ncurses-library","pdcurses","styled-components","tui"],"created_at":"2024-10-11T09:44:54.951Z","updated_at":"2025-04-09T18:19:23.583Z","avatar_url":"https://github.com/okbob.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ncurses-st-menu \n\nmodern and simple ncurses/PDCurses based library for CUA look menu\n\nI didn't find any library for Unix terminal applications for creating pull down and menu bar menus. \nMy short target is library for menu with midnight commander look. The origin ncurses menu are not designed\nfor CUA applications, and cannot be used for these types of applications. This is library - small library.\nIt does only pulldown menus and menubars, nothing else. It is not complex framework with thousand functions.\n\n# Features\n\n* CUA look pulldown and menu bar support\n\n* Support inner accelerator ~x~ and outer accelerator _x_\n\n* Menubar are accessable via Alt x accelerators\n\n* Nested pulldown menu are suppported\n\n* Possible to set style (14 attributes, 12 styles are prepared)\n\n* Possible to set shadow around pulldown menu\n\n* Mouse is supported\n\n* Possible serialize and load state of menu objects\n\n* Menu is scrollable when has more items than can be displayed\n\n* The usage pattern is close to original ncurses `menu` library. A menudata are\n  created by functions `st_menu_new` or `st_menu_new_menubar`. A function `st_menu_post`\n  displays menu, and function `st_menu_unpost` hides menu. Any event can be processed\n  in menu library by function `st_menu_driver` and menu can be removed by function \n  `st_menu_free`.\n\n* Compatible with PDCurses (offers Windows support--among others)\n\n# Screenshots\n\n![](screenshots/small/scr1.png)\n![](screenshots/small/scr2.png)\n![](screenshots/small/scr4.png)\n![](screenshots/small/scr6.png)\n![](screenshots/small/scr8.png)\n\n\n# Building Libraries/Demos\n\nUse the following to build for ncurses.  (PDCurses specific build information is detailed later in this document)\n```\n./autogen.sh\n./configure\nmake\n```\n\nNOTE: To generate a debug build append `--enable-debug` to the configure statement.\n\nCreates `demoapp` and `demoapp_sl`. `demoapp_sl` uses shared library - and it can be executed by\n`LD_LIBRARY_PATH=. ./demoapp_sl`. Note: when you doesn't modify `LD_LIBRARY_PATH`, you should\nto run `make install` for correct behave of `demoapp_sl` (demo with shared library).\n\n`Command|Set style` submenu is active - you can change styles interactivly.\n\nWhen there are no `ncursesw` library, then modify Makefile and replace `ncursesw` by `necurses`,\nand remove `-DNCURSES_WIDECHAR=1`.\n\n## Clean Build\n\nTo remove all built objects/executable/etc run:\n\n```\nmake clean\n```\n\nTo remove the files created by the autotools as well as objects/executable/etc:\n\n```\nmake cleanall\n```\n\n# Usage\n```C\n#ifdef HAVE_LANGINFO_CODESET\n#include \u003clanginfo.h\u003e\n#endif\n#include \u003clocale.h\u003e\n#include \"st_curses.h\"\n#include \"st_panel.h\"\n#include \u003cstring.h\u003e\n#include \u003cunicase.h\u003e\n\n#include \"st_menu.h\"\n\n/*\n * Read event. When event is mouse event, read mouse data\n */\nstatic inline int\nget_event(MEVENT *mevent, bool *alt)\n{\n\tbool\tfirst_event = true;\n\tint\t\tc;\n\n\t*alt = false;\n\nrepeat:\n\n\tc = getch();\n\n\t/*\n\t * Read mouse event when it is possible. Do it now, before st_menu_driver call,\n\t * as protection to unwanted multiple call of getmouse function. For one mouse\n\t * event, it returns data only once time.\n\t */\n\tif (c == KEY_MOUSE)\n\t{\n\t\tint ok = getmouse(mevent);\n\n\t\tif (ok != OK)\n\t\t\tgoto repeat;\n\t}\n\n\tif (c == ST_MENU_ESCAPE)\n\t{\n\t\tif (first_event)\n\t\t{\n\t\t\tfirst_event = false;\n\t\t\tgoto repeat;\n\t\t}\n\t}\n\n\t*alt = !first_event;\n\n\treturn c;\n}\n\n/*\n * Application demo\n */\nint\nmain()\n{\n\tPANEL *mainpanel;\n\tST_MENU_CONFIG  config;\n\tST_MENU_ITEM\t\t   *active_item;\n\tstruct ST_MENU *menu;\n\tbool\tactivated;\n\tint\t\tc;\n\tMEVENT\tmevent;\n\tbool\talt;\n\tbool\tforce8bit;\n\n\tST_MENU_ITEM _file[] = {\n\t\t{\"E~x~it\", 34, \"Alt-x\"},\n\t\t{NULL, -1, NULL}\n\t};\n\n\tST_MENU_ITEM menubar[] = {\n\t\t{\"~F~ile\", 61, NULL, 0, _file},\n\t\t{NULL, -1, NULL}\n\t};\n\n\tsetlocale(LC_ALL, \"\");\n\n    #ifdef HAVE_LANGINFO_CODESET\n\t/* Don't use UTF when terminal doesn't use UTF */\n\tconfig.encoding = nl_langinfo(CODESET);\n\t#else\n\tconfig.encoding = \"\";\n\t#endif\n\n#ifdef LIBUNISTRING\n\n\tconfig.language = uc_locale_language();\n\n#else\n\n\tconfig.language = NULL;\n\n#endif\n    \n\tforce8bit = strcmp(config.encoding, \"UTF-8\") != 0;\n\n\tinitscr();\n\tstart_color();\n\tclear();\n\tcbreak();\n\tnoecho();\n\tkeypad(stdscr, TRUE);\n\n#ifdef NCURSES_EXT_FUNCS\n\n\tset_escdelay(25);\n\n#endif\n\n\trefresh();\n\n\tinit_pair(1, COLOR_WHITE, COLOR_BLUE);\n\n\t/* load style, possible alternatives: ST_MENU_STYLE_MC, ST_MENU_STYLE_DOS */\n\tst_menu_load_style(\u0026config, ST_MENU_STYLE_VISION, 2, force8bit, false);\n\n\tmousemask(BUTTON1_PRESSED | BUTTON1_RELEASED, NULL);\n\tmouseinterval(0);\n\n\t/* prepare main window */\n\twbkgd(stdscr, COLOR_PAIR(1));\n\twclear(stdscr);\n\twrefresh(stdscr);\n\n\t/*\n\t * main window should be panelized. Only panels can be\n\t * overlapped without unwanted effects.\n\t */\n\tmainpanel = new_panel(stdscr);\n\tst_menu_set_desktop_panel(mainpanel);\n\n\t/* prepare state variable for menubar */\n\tmenu = st_menu_new_menubar(\u0026config, menubar);\n\n\t/* post meubar (display it) */\n\tst_menu_post(menu);\n\n\tc = get_event(\u0026mevent, \u0026alt);\n\n\trefresh();\n\n\twhile (1)\n\t{\n\t\tbool\tprocessed = false;\n\n\t\tprocessed = st_menu_driver(menu, c, alt, \u0026mevent);\n\n\t\tdoupdate();\n\n\t\tactive_item = st_menu_selected_item(\u0026activated);\n\t\tif (processed \u0026\u0026 activated)\n\t\t{\n\t\t\t/* here is processing of menucode related to Exit menu item */\n\t\t\tif (active_item-\u003ecode == 34)\n\t\t\t\tbreak;\n\t\t}\n\n\t\tif (!processed \u0026\u0026 alt \u0026\u0026 c == 'x')\n\t\t\tbreak;\n\n\t\t/* get new event */\n\t\tc = get_event(\u0026mevent, \u0026alt);\n\t}\n\n\tendwin();\n\n\tst_menu_unpost(menu, true);\n\tst_menu_free(menu);\n\n\treturn 0;\n}\n```\n\n# Dependency\n\n* optional libunistring - LGPL Unicode library\n\n* define NCURSES_WIDECHAR when wide char ncurses support is available.\n\n\n# PDCurses\n\n\n## Building PDCurses\n\nThis is a simple overview on building PDcurses from source.  For the latest info refer to the README files for each build directory/type.\n\n### X11\n\n```\ncd PDCurses/x11\n./configure\nmake\n```\n\n### wincon (Windows Console)\n\nBuilding with MinGW using MSys\n\n```\ncd PDCurses/wincon\nset PDCURSES_SRCDIR=c:\\tmp\\PDCurses\nmake DLL=Y\n```\n\nNOTE: To clean the build you will need to run `rm *.o *.dll *.a` since `make clean` was written expecting to run from a Windows Console (i.e. uses DEL).\n\n\n## Building for PDCurses\n\nTo build for PDCurses you first need some added agruments for the `configure` prior to the make.  The configure options are defined as:\n\n**PDCURSES_INSTALL**    If you have the PDCurses libs/headers installed you can \n                        simply use just this flag.  The other options will be\n                        filled in for you.  Currently support: \"x11\"\n                        NOTE: Other arguments not needed.                  \u003cbr\u003e\n**PDCURSES_INCDIR**     Directory containing the curses/panel headers      \u003cbr\u003e\n**PDCURSES_LIBDIR**     Directory containing the PDCurses library          \u003cbr\u003e\n**PDCURSES_LIB**        Name of the PDCurses library, defaults to 'libXCurses' (Linux), 'pdcurses' (Windows) \u003cbr\u003e\n**PDCURSES_DEP_LIBS**   List of the PDCurses dependant library (exclude PDCURSES_LIB).           \u003cbr\u003e\n \nNOTE: If you are pointing to the PDCurses github directory built for\n      a specific OS/terminal you can omit the PDCURSES_INCDIR.\n\n### Windows Requirements\n\nBuilt using MinGW from MSys.  Install the following:\n- pacman -S mingw-w64-x86_64-pkg-config\n- pacman -S automake autoconf\n\n### Examples\n\nThis example builds from installed PDCurses for Linux X11:                \u003cbr\u003e\nNOTE: The build tools will setup all the other `PDCURSES_xxx` arguments for us.\n\n```\n./autogen.sh\nPDCURSES_INSTALL=x11 ./configure\nmake\n```\n\nThis example builds from PDCurses source for Linux X11:                   \u003cbr\u003e\nNOTE: PDCURSES_LIB defaults to `libXCurses` so we don't need to specify it\n\n```\n./autogen.sh\nPDCURSES_LIBDIR=/home/username/github/PDCurses/x11 ./configure\nmake\n```\n\nThis is a complete example (ignores the fact that some variables are not needed):\n```\n./autogen.sh\nPDCURSES_LIBDIR=/home/username/github/PDCurses/x11 \\\nPDCURSES_INCDIR=/home/username/github/PDCurses \\\nPDCURSES_LIB=libXCurses \\\nPDCURSES_DEP_LIBS=Xaw Xmu Xt X11 Xpm SM ICE Xext \\\n./configure\nmake\n```\n\nThis example builds from PDCurses source for Windows:\n\n```\n./autogen.sh\nPDCURSES_LIBDIR=/c/tmp/PDCurses/wincon ./configure\nmake\n```\n\nNOTE: To generate a debug build append `--enable-debug` to the configure statement.\n\n\n## Screenshots\n\nPDCurses Ubuntu 16.04 X11 \n![](screenshots/scr12.png)\n\n\n## PDCurses Tested:\n\n- Ubuntu 16.04, PDCurses X11\n- Windows 10, PDCurses wincon\n  - Build with MSys/MinGW\n\n# Note\n\nIf you like it, send a postcard from your home country to my address, please:\n\n    Pavel Stehule\n    Skalice 12\n    256 01 Benesov u Prahy\n    Czech Republic\n\n\nI invite any questions, comments, bug reports, patches on mail address pavel.stehule@gmail.com\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fokbob%2Fncurses-st-menu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fokbob%2Fncurses-st-menu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fokbob%2Fncurses-st-menu/lists"}