• Stars
    star
    531
  • Rank 83,526 (Top 2 %)
  • Language
    C++
  • License
    GNU General Publi...
  • Created over 7 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

The eternal text editor — Didactic Ersatz Emacs to show immutable data-structures and the single-atom architecture

Build Status

ewig is a simple text editor (an Ersatz Emacs) written using immutable data-structures in C++.

The code is written in a simple style to showcase a value-based functional architecture. We invite you to study the code. Learn more in the CppCon'17 Talk: Postmodern Immutable Data Structures.

This project is part of a long-term vision helping interactive and concurrent C++ programs become easier to write. Help this project's long term sustainability by becoming a patron or buying a sponsorship package: [email protected]


Try it out

If you are using the Nix package manager (we strongly recommend it) you can just install the software with.

    nix-env -if https://github.com/arximboldi/ewig/archive/master.tar.gz

Development

To build the code you need a C++17 compiler, cmake, and ncurses with unicode support (package libncursesw5-dev in Debian and friends).

You can install those manually, but the easiest way to get a development environment up and running is by using the Nix package manager. At the root of the repository just type:

    nix-shell

This will download all required dependencies and create an isolated environment in which you can use these dependencies, without polluting your system.

Then you can generate a development project using CMake.

    mkdir build && cd build
    cmake ..

To configure an optimized build and compile do:

    cmake .. -DCMAKE_BUILD_TYPE=Release
    make

To install the compiled software globally:

    sudo make install

Keybindings

Excerpt from main.cpp:

const auto key_map_emacs = make_key_map(
{
    {key::seq(key::ctrl('p')), "move-up"},
    {key::seq(key::up),        "move-up"},
    {key::seq(key::down),      "move-down"},
    {key::seq(key::ctrl('n')), "move-down"},
    {key::seq(key::ctrl('b')), "move-left"},
    {key::seq(key::left),      "move-left"},
    {key::seq(key::ctrl('f')), "move-right"},
    {key::seq(key::right),     "move-right"},
    {key::seq(key::page_down), "page-down"},
    {key::seq(key::page_up),   "page-up"},
    {key::seq(key::backspace), "delete-char"},
    {key::seq(key::backspace_),"delete-char"},
    {key::seq(key::delete_),   "delete-char-right"},
    {key::seq(key::home),      "move-beginning-of-line"},
    {key::seq(key::ctrl('a')), "move-beginning-of-line"},
    {key::seq(key::end),       "move-end-of-line"},
    {key::seq(key::ctrl('e')), "move-end-of-line"},
    {key::seq(key::ctrl('i')), "insert-tab"}, // tab
    {key::seq(key::ctrl('j')), "new-line"}, // enter
    {key::seq(key::ctrl('k')), "kill-line"},
    {key::seq(key::ctrl('w')), "cut"},
    {key::seq(key::ctrl('y')), "paste"},
    {key::seq(key::ctrl('@')), "start-selection"}, // ctrl-space
    {key::seq(key::ctrl('_')), "undo"},
    {key::seq(key::ctrl('x'), key::ctrl('C')), "quit"},
    {key::seq(key::ctrl('x'), key::ctrl('S')), "save"},
    {key::seq(key::ctrl('x'), 'h'), "select-whole-buffer"},
    {key::seq(key::ctrl('x'), '['), "move-beginning-buffer"},
    {key::seq(key::ctrl('x'), ']'), "move-end-buffer"},
    {key::seq(key::alt('w')),  "copy"},
});

License

This software is licensed under the GPLv3 license.

Copyright (C) 2016 Juan Pedro Bolivar Puente

This file is part of ewig.

ewig is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

ewig is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with ewig.  If not, see <http://www.gnu.org/licenses/>.

GPL3 Logo