lionkor / commandline Goto Github PK
View Code? Open in Web Editor NEWA C++ commandline for use in servers and chat software. Provides very simple asynchronous input/output.
License: MIT License
A C++ commandline for use in servers and chat software. Provides very simple asynchronous input/output.
License: MIT License
The InteractiveBackend
is only used if is_interactive()
returns true, so there's no need to check for that in the implementation anymore.
is_interactive
uses from InteractiveBackend
Backend
functionsscreen -dmS test commandline_test
screen -r test
and observe completely bugged inputscreen -dmS
should work as expectedNotes
In CMakelists.txt - line 23.
if(BUILD_EXAMPLES)`
add_executable(test main.cpp)
target_link_libraries(test commandline)
set_property(DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT test)
endif()
The target "test" is reserved and will cause cmake to fail configuration when CTest testing is enabled.
Suggest changing the target name.
Thank you for the commandline library!
When pressing Up-Arrow on the keyboard, the last entered command should appear. Pressing this repeatedly will go through all entered commands in the current session in reverse-chronological order. Down-Arrow then should do the opposite, ending up at the current prompt.
It doesn't do this properly on (all?) windows machines (CMD).
Currently we're using ANSI escape codes on both Unix/Linux/MacOS and Windows, which causes issues in Windows (of course).
They decided that Powershell and the Windows Terminal (!= CMD) should not behave properly when presented with ANSI escape codes, even with that feature explicitly enabled.
So, instead of getting really angry with windows' decisions, we are just going to use their WinAPI features to do what we do with ANSI escape sequences currently.
Snarkiness aside, the goal is to replace all ANSI escape codes (\0x1b
prefixed stuff in all calls to printf
) with the equivalent Windows API function call.
Add autocomplete :^)
Replace header guards with #pragma once
When building x64-osx (vcpkg):
/Users/vagrant/Data/buildtrees/commandline/src/a4454e07a9-613e01ad85.clean/commandline.cpp:11:10: fatal error: 'conio.h' file not found
#include <conio.h>
^~~~~~~~~
1 error generated.
Originally posted by @JackBoosY in microsoft/vcpkg#23471 (comment)
Hi!
Nice library right here!
I wonder if it is possible to have some text prompting the user to input something.
Currently, calling get_command
without checking has_command
invokes implementation defined behavior (i.e. in both currently present backends an exception).
I am struggling to get standard input to work from my C# Console Application...
process.StandardInput.WriteLine("help" + Environment.NewLine);
process.StandardInput.Flush();
I've tested with and without the newline and flushing...
Quote Lion:
just replace the true in the code i linked with _isatty(stdin) && _isatty(stdout)
windows_impl.cpp#L8
Discord Message
on_autocomplete currently passes in the current cursor position, in order to allow autocomplete within a word/sentence at a specific point. This is nice, but not as useful as it could be, because the cursor will end up at the end of the autocompletion, which is the end of the entire input.
We need a way to set the cursor's position generally, like c.set_cursor_position()
, but it also has to be understood by the caller of on_autocomplete whether or not this has been called. If it was called, dont put the cursor at the end, and if it wasn't, do.
The current CMakeLists has a few bad decisions, the wrong version requirement, and a few other issues.
Rewrite it to make it conform to a newer standard, while going down in required version number (to support older codebases, see #10).
Shift+tab should go backwards through suggestions
The codebase does not require modern C++ (14, 17), as far as I can see. I'd like to see us move all code to C++11, and enforce this in the CMakeLists.
As a result, commandline can be integrated into more C++ projects.
The on_autocomplete
callback should give the position of the cursor, to allow for more complex autocomplete inside expressions.
This is partially supported already, just needs to be implemented. The idea is moving the cursor via left & right arrow keys. See m_cursor_pos
for this.
Hey, nice library. I am wondering if it makes sense to move the atexit function restoring termios to just the destructor of the commandline? I have a server that handles SIGINT in order to gracefully store stuff to disk and then immediately _exit in order to avoid having to tearing down multi-gigabytes of structures. Guess it's just one of those weird cases.
For now I am just calling the atexit handler in the destructor ๐
The library should figure out how long the terminal line is (or similar) and wrap long lines properly. Currently, long input lines are mostly broken.
Currently, the delete key does not work. This wasn't implemented originally, because cursor movement didn't exist.
HOME and END keys don't work in some shells. This needs further testing to confirm.
Pressing Up arrow or Down arrow produce visible characters instead of doing nothing when the history is empty.
Related to BeamMP/BeamMP-Server#206
Does not build on MacOS.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.