hellerve / e Goto Github PK
View Code? Open in Web Editor NEWA dead simple editor
License: The Unlicense
A dead simple editor
License: The Unlicense
GCC version.
$ cc --version
cc (Ubuntu 6.3.0-12ubuntu2) 6.3.0 20170406
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Errors.
$ make
mkdir -p /home/foobar/.estx
cp stx/* /home/foobar/.estx
mkdir -p bin/
cc main.c src/clipboard.c src/editor.c src/buffer.c src/util.c src/colors.c src/syntax.c -DSTXDIR=\"/home/foobar/.estx\" -o bin/e -Werror -Wall -g -fPIC -O2 -DNDEBUG -ftrapv -Wfloat-equal -Wundef -Wwrite-strings -Wuninitialized -pedantic -std=c11
src/editor.c: In function ‘e_die’:
src/editor.c:24:3: error: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Werror=unused-result]
write(STDOUT_FILENO, "\x1b[2J\x1b[?47l\x1b""8", 12);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/editor.c: In function ‘e_exit’:
src/editor.c:31:3: error: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Werror=unused-result]
write(STDOUT_FILENO, "\x1b[2J\x1b[?47l\x1b""8", 12);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/editor.c: In function ‘e_clear_screen’:
src/editor.c:214:3: error: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Werror=unused-result]
write(STDOUT_FILENO, ab.b, ab.len);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/editor.c: In function ‘e_setup’:
src/editor.c:1214:3: error: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Werror=unused-result]
write(STDOUT_FILENO, "\x1b""7\x1b[?47h", 8);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
src/syntax.c: In function ‘syntax_read_extensions’:
src/syntax.c:26:5: error: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Werror=unused-result]
fgets(line, MAX_LINE_WIDTH, f);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/syntax.c: In function ‘syntax_read_pattern’:
src/syntax.c:55:5: error: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Werror=unused-result]
fgets(line, MAX_LINE_WIDTH, f);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
Makefile:11: recipe for target 'all' failed
make: *** [all] Error 1
On WSL, e usually doesn't respond to key presses on first click. It is more apparent on ESC to exit. It is either WSL related if it only occurs on it, otherwise Linux related.
I just downloaded e for both Raspberry Pi (arm) and MAC OSX. e compiled cleanly on both machines however I get a segmentation fault on Raspberry Pi. Runs cleanly on Mac. Just an FYI.
The cases I've seen:
Hi,
Have you put any consideration into the license you plan to use for e? I'm working on a FreeBSD port at the minute and it would be great to be able to put that into the initial port submission.
For reasons I’m not entirely certain of at the moment, pressing when working with a binary file leads to a segmentation fault. It seems to be related with drawing, but pressing shouldn’t do anything in edit mode, so I’m a bit confused.
Cheers
Hey, when I try to make install
on Fedora 25 I get this. Any ideas?
❯ make install
mkdir -p /home/oskar/.estx
cp stx/* /home/oskar/.estx
mkdir -p bin/
cc main.c src/editor.c src/buffer.c src/util.c src/colors.c src/syntax.c -DSTXDIR=\"/home/oskar/.estx\" -o bin/e -Werror -Wall -g -fPIC -O2 -DNDEBUG -ftrapv -Wfloat-equal -Wundef -Wwrite-strings -Wuninitialized -pedantic
In file included from main.c:3:0:
src/editor.h:1:0: error: "_DEFAULT_SOURCE" redefined [-Werror]
#define _DEFAULT_SOURCE
In file included from /usr/include/signal.h:28:0,
from main.c:1:
/usr/include/features.h:185:0: note: this is the location of the previous definition
# define _DEFAULT_SOURCE 1
cc1: all warnings being treated as errors
Makefile:10: recipe for target 'all' failed
make: *** [all] Error 1
WASD is not ergonomic on some keyboard layouts, and it would be a good idea to create a simple way to change them. Currently, we do these movements in a switch
statement, meaning we cannot have non-constants. It would make sense to make this scriptable through Lua, though.
Thanks to this comment on HN for making me aware of this issue.
Related to #28: when using new-fangled Unicode fetures like skin-tone modifiers or emoji ligatures, the cursor becomes very unhappy as well. It is sort of the reverse problem that we have with full-width characters. We should probably handle all of those problems in one fell (and hopefully graceful) swoop.
Fullwidth characters, such as kana (e.g. なんでやねん
) or even fullwidth roman characters (e.g. oh no
) confuse the cursor: it gets place at a normal halfwidth position, which is obviously wrong. Example:
This does not affect the capabilities of editing such a text, but the application still becomes more or less useless, because the cursor position is not correct.
As reported in this comment, e
exits with error code 13 on some Linux systems.
On WSL Ubuntu 16.04, all lines start 0
, and the cursor is one/two to the left of where it should be.
cp ./poc.stx ./stx
run ./bin/e
touch a file contains "\x00\x00\x00\x00" like poc.stx. run
fgets not return NULL but strlen return 0. so "ln =-1", line[ln] will error.
while (fgets(line, MAX_LINE_WIDTH, f)) {
lineno++;
ln = strlen(line)-1;
line[ln] = '\0'; //error
}
==2851==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x61d00001ea7f at pc 0x00000040d428 bp 0x7ffd417b66f0 sp 0x7ffd417b66e0
WRITE of size 1 at 0x61d00001ea7f thread T0
#0 0x40d427 in syntax_read_file src/syntax.c:126
#1 0x40d5d0 in syntax_init src/syntax.c:174
#2 0x401d69 in main /home/fuzz/github/e_bak/main.c:49
#3 0x7f32df71e82f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
#4 0x401fc8 in _start (/home/fuzz/github/e_bak/bin/e+0x401fc8)
0x61d00001ea7f is located 1 bytes to the left of 2048-byte region [0x61d00001ea80,0x61d00001f280)
allocated by thread T0 here:
#0 0x7f32dfb60602 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98602)
#1 0x40d17e in syntax_read_file src/syntax.c:109
SUMMARY: AddressSanitizer: heap-buffer-overflow src/syntax.c:126 syntax_read_file
Shadow bytes around the buggy address:
0x0c3a7fffbcf0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c3a7fffbd00: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c3a7fffbd10: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c3a7fffbd20: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c3a7fffbd30: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
=>0x0c3a7fffbd40: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa[fa]
0x0c3a7fffbd50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c3a7fffbd60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c3a7fffbd70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c3a7fffbd80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c3a7fffbd90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Heap right redzone: fb
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack partial redzone: f4
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
==2851==ABORTING
testcase:https://github.com/xcainiao/poc/blob/master/e_heap-buffer-overflow_syntax_read_file.stx
Currently there is a global variable E_TAB_WIDTH
that tells us how wide the tab should be. This shouldn't be too hard to convert into a local variable in the editor state.
Tabs are spaces in e
, because I like it that way. I am not very opinionated about this, however, and realize other people have strong dissenting opinions on this.
I personally always use spaces, so I didn’t notice this before, but it seems that certain combinations of tabs and spaces lead to non-alignment when the cursor moves down/up.
I’m not able to provide a minimal test case yet.
In INIT mode, if you type 'h' to "hide" on an empty line, follow it then with an additional 'h' with cause e to crash on Ubuntu 16.04 and Fedora 26 respectfully.
I tried to compile the editor with lua support, and the make install_lua
is failing. The make
, and make install
is running without problem.
Make output
If there are syntax errors in coloring files (regcomp returns a non-null value), e exits abruptly without a message.
Line 31 in 0e6ed83
This needs to be fixed, but I currently only develop on OS X. Any help would be appreciated.
Cheers
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.