Giter Club home page Giter Club logo

tclib's People

Contributors

darkuranium avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

tclib's Issues

[tc_history] Read/write history from/to file or stream

Right now, all history is discarded on exit. It should be read or written from/to a file or a custom stream.

This might require another dependency, tc_stream (since I expect that to be needed for some other libraries as well).

[tc_editline] Add callbacks for tab completion and hints

Currently, only a single callback exists. Instead, multiple events should be recognized and passed to the user.

I have already decided to go with option nr. 3, but for the record, there were three options:

  1. N callbacks registered separately

    void tcedit_register_tabcomplete(int (*cb)(<...>), void* udata);
    void tcedit_register_echo(<...>, void* udata);
  2. N callbacks registered at once (via a struct)

    typedef struct TC_EditHandler {
        int (*tabcomplete)(<...>);
        <...>
        void* udata;
    } TC_EditHandler;
    void tcedit_register_handler(TC_EditHandler* handler);
  3. A single callback which is passed an event type.

    typedef struct TC_EditEvent {
        int type;
        TC_String* input;
        <...>
    } TC_EditEvent;
    typedef int TC_EditCallback(TC_EditEvent* event, void* udata);
    void tcedit_register_callback(TC_EditCallback* callback, void* udata);

[tc_terminal] Add `TCTERM_{FG,BG}_DEFAULT` for default color

Windows and POSIX handle colors differently --- in POSIX, one can use \e[39m (foreground) or \e[0m (both) to reset the colors. For that purpose, TCTERM_FG_DEFAULT and TCTERM_BG_DEFAULT should be added, which resolve to some system-specific "default" color.

Perhaps TCTERM_{FG,BG}_STARTING should also be added to specify the selected color at program start (which is distinct from the default color of the terminal).

[tc_terminal] Fix `tcterm_get_cursor_pos()`

The tcterm_get_cursor_pos() function currently flushes all input in order to get the data in POSIX — that should be fixed.

The best way to do that is to take advantage of buffering (depends on #12 being implemented), then do a flush and fetch position. The CREAD flag might perhaps be helpful here.

Add an option for custom `malloc()`, `memcpy()` and friends

Custom allocators can be very useful, so support should be added.

The simplest method is via #defines:

#define TC_MALLOC(size) my_malloc(size)
#define TC_MEMCPY(dst, src, size) my_memcpy(dst, src, size)

... however, a method that can pass some sort of user data should be devised (to avoid globals).

[tc_string] Implement `tcstr_utf8_find_offset()`

The tc_string library has a tcstr_utf8_find_char(str, off) function, which finds the Unicode code point index for a given offset.

The inverse function for that is missing and should be implemented.

[tc_history] [tc_editline] Add multiline support

The libraries are limited to getting (and storing in history) only a single line of input. This should be added.

Some sort of an API is needed to provide support for this.

Example (in a shell):

$ echo '
foo
bar'
> foo
bar
# (( up arrow key ))
$ echo '
foo
bar'

Implement proper testing

The libraries which can be tested effectively (which is most of them at the moment), should get some tests made — perhaps with continuous integration.

[tc_terminal] Add input buffering

Currently, tcterm_getc() is the only way of getting input and it is slow. For that purpose, buffering and/or some sort of a tcterm_read() should be added.

Get the libraries to compile with a C++ compiler

Currently, the libraries are strictly C. They should be changed so that they can be compiled with a C++ compiler. This mostly involves adding extern "C" and explicit void*T* casts.

Furthermore, @q66 has asked me to make it compile with -Wold-style-cast, which means adding something akin to:

#ifdef __cplusplus
#define TC_STATIC_CAST(T,val)  static_cast<T>(val)
#else
#define TC_STATIC_CAST(T,val)  ((T)(val))
#endif

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.