Skip to content

Commit cb8c0a1

Browse files
committed
add terminal support
1 parent f1e523d commit cb8c0a1

38 files changed

Lines changed: 13957 additions & 1 deletion

lib/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ SUB_DIR := libscm libgui libc libcffi libgl\
1616
libalut \
1717
libvideo \
1818
libglut libimgui \
19+
libterminal
1920

2021
LIBSCM =./libscm/libscm.so
2122
LIBGLUT =./libglut/libglut.so

lib/libgui/edit.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -911,6 +911,9 @@ void edit_key_event(edit_t *self, int key, int scancode, int action, int mods) {
911911
}
912912

913913
void render_cursor(edit_t *self) {
914+
if(self->cursor_visible==0){
915+
return;
916+
}
914917
float dx = 0, dy = 0;
915918
buffer_t *buffer = self->buffer;
916919
float sx = self->bound.left + self->lineno_width;
@@ -988,6 +991,9 @@ void edit_set_select_color(edit_t *self, int color) {
988991
void edit_set_cursor_color(edit_t *self, int color) {
989992
self->cursor_color = color;
990993
}
994+
void edit_set_cursor_visible(edit_t* self,int visible){
995+
self->cursor_visible=visible;
996+
}
991997

992998
edit_t *new_edit(int shader, font_t *font, float font_size, float scale,
993999
float w, float h, float width, float height) {
@@ -1033,6 +1039,7 @@ edit_t *new_edit(int shader, font_t *font, float font_size, float scale,
10331039
self->show_lineno = 0;
10341040
self->lineno_color = -1;
10351041
self->lineno_width = 0;
1042+
self->cursor_visible=1;
10361043

10371044
update_cursor_pos(self->buffer);
10381045

lib/libgui/edit.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ typedef struct _edit_t {
7575
int selected_bg_color;
7676
int select_press;
7777
int cursor_color;
78+
int cursor_visible;
7879

7980
int show_lineno;
8081
int lineno_width;

lib/libgui/graphic.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ void glShaderSource2(GLuint shader, GLsizei count, const GLchar* string,
197197
glShaderSource(shader, count, &string, length);
198198
}
199199

200-
void graphic_render_prepare_string(mvp_t* mvp, font_t* font) {
200+
void graphic_set_mvp(mvp_t* mvp){
201201
glUseProgram(mvp->shader);
202202
glUniform1i(glGetUniformLocation(mvp->shader, "texture"), 0);
203203
glUniformMatrix4fv(glGetUniformLocation(mvp->shader, "model"), 1, 0,
@@ -207,6 +207,10 @@ void graphic_render_prepare_string(mvp_t* mvp, font_t* font) {
207207
glUniformMatrix4fv(glGetUniformLocation(mvp->shader, "projection"), 1, 0,
208208
mvp->projection.data);
209209
glUniform1i(glGetUniformLocation(mvp->shader, "type"), 1);
210+
}
211+
212+
void graphic_render_prepare_string(mvp_t* mvp, font_t* font) {
213+
graphic_set_mvp(mvp);
210214
sth_begin_draw(font->stash);
211215
}
212216

lib/libterminal/Makefile

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
##########################################################
2+
# Copyright 2016-2080 evilbinary.
3+
#作者:evilbinary on 12/24/16.
4+
#邮箱:rootdebug@163.com
5+
##########################################################
6+
7+
8+
TARGET = libterminal.so
9+
OBJS = terminal.o \
10+
libtsm/src/shl_htable.o \
11+
libtsm/src/tsm_render.o \
12+
libtsm/src/tsm_screen.o \
13+
libtsm/src/tsm_selection.o \
14+
libtsm/src/tsm_unicode.o \
15+
libtsm/src/tsm_vte.o \
16+
libtsm/src/tsm_vte_charsets.o \
17+
libtsm/external/wcwidth.o \
18+
shl_pty.o \
19+
20+
PLATFORM=
21+
BITS =$(shell getconf LONG_BIT)
22+
23+
24+
LIBS = -L./libtsm/src -L../libgui -lgui -L../libgl -lgles
25+
CFLAGS = -DGLAD -Wall -Wformat -I. -I./libtsm/src -I./libtsm/ -I./libtsm/external -I../libgui -I../libgl #-g
26+
27+
CXXFLAGS= -Wall -Wformat
28+
29+
UNAME_S := $(shell uname -s)
30+
ifeq ($(UNAME_S), Linux) #LINUX
31+
ECHO_MESSAGE = "Linux"
32+
LIBS +=
33+
CXXFLAGS +=
34+
CXXFLAGS +=
35+
CFLAGS += -fPIC
36+
ifeq ($(BITS), 32)
37+
PLATFORM=i3le
38+
else
39+
PLATFORM=a6le
40+
endif
41+
endif
42+
43+
ifeq ($(UNAME_S), Darwin) #APPLE
44+
ECHO_MESSAGE = "Mac OS X"
45+
LIBS +=
46+
CXXFLAGS +=
47+
CXXFLAGS +=
48+
CFLAGS +=
49+
ifeq ($(BITS), 32)
50+
PLATFORM=i3osx
51+
else
52+
PLATFORM=a6osx
53+
endif
54+
# CXXFLAGS += -D__APPLE__
55+
endif
56+
57+
ifeq ($(UNAME_S), MINGW32_NT-6.1)
58+
ECHO_MESSAGE = "Windows"
59+
LIBS += -lm
60+
CXXFLAGS +=
61+
CXXFLAGS +=
62+
CFLAGS += #-Wno-implicit-function-declaration -Wl,--export-all-symbols -Wl,--exclude-all-symbols
63+
PLATFORM=i3nt
64+
TARGET = libc.dll
65+
66+
endif
67+
68+
.cpp.o:
69+
$(CXX) $(CXXFLAGS) -c -o $@ $<
70+
.c.o:
71+
$(CC) $(CFLAGS) -c -o $@ $<
72+
all: $(TARGET)
73+
@echo Build complete for $(ECHO_MESSAGE)
74+
75+
$(TARGET): $(OBJS)
76+
$(CC) $(CFLAGS) $(OBJS) -shared -o $(TARGET) $(LIBS)
77+
78+
clean:
79+
rm -rf $(TARGET) $(OBJS)
80+

lib/libterminal/libtsm/COPYING

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
= Authors =
2+
3+
This software was written by:
4+
David Herrmann <dh.herrmann@gmail.com>
5+
Ran Benita <ran234@gmail.com>
6+
7+
= Copyright Notice =
8+
9+
This software is licensed under the terms of the MIT license. Please see each
10+
source file for the related copyright notice and license.
11+
12+
If a file does not contain a copright notice, the following license shall
13+
apply:
14+
15+
Copyright (c) 2011-2013 David Herrmann <dh.herrmann@gmail.com>
16+
17+
Permission is hereby granted, free of charge, to any person obtaining
18+
a copy of this software and associated documentation files
19+
(the "Software"), to deal in the Software without restriction, including
20+
without limitation the rights to use, copy, modify, merge, publish,
21+
distribute, sublicense, and/or sell copies of the Software, and to
22+
permit persons to whom the Software is furnished to do so, subject to
23+
the following conditions:
24+
25+
The above copyright notice and this permission notice shall be included
26+
in all copies or substantial portions of the Software.
27+
28+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
29+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
30+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
31+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
32+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
33+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
34+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35+
36+
== Third-Party Source ==
37+
38+
The hash-table implementation in external/htable.* is copied from ccan and
39+
licensed under the conditions of the LGPL-2.1 or later as published by the FSF:
40+
41+
Author: Rusty Russel <rusty@rustcorp.com.au>
42+
43+
The wcwidth() implementation in ./external/wcwidth.c is from:
44+
45+
Markus Kuhn -- 2007-05-26 (Unicode 5.0)
46+
47+
Permission to use, copy, modify, and distribute this software
48+
for any purpose and without fee is hereby granted. The author
49+
disclaims all warranties with regard to this software.
50+
51+
Latest version: http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c
52+
53+
UCS-4 to UTF-8 encoding is copied from "terminology":
54+
55+
Copyright (C) 2012-2012 Carsten Haitzler and various contributors
56+
57+
All rights reserved.
58+
59+
Redistribution and use in source and binary forms, with or without
60+
modification, are permitted provided that the following conditions are
61+
met:
62+
63+
1. Redistributions of source code must retain the above copyright
64+
notice, this list of conditions and the following disclaimer.
65+
2. Redistributions in binary form must reproduce the above copyright
66+
notice, this list of conditions and the following disclaimer in the
67+
documentation and/or other materials provided with the distribution.
68+
69+
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
70+
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
71+
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
72+
THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
73+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
74+
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
75+
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
76+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
77+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
78+
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
79+
80+
The "solarized" color palettes in tsm_vte.c are from:
81+
82+
Copyright (c) 2011 Ethan Schoonover
83+
84+
Permission is hereby granted, free of charge, to any person obtaining a copy
85+
of this software and associated documentation files (the "Software"), to deal
86+
in the Software without restriction, including without limitation the rights
87+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
88+
copies of the Software, and to permit persons to whom the Software is
89+
furnished to do so, subject to the following conditions:
90+
91+
The above copyright notice and this permission notice shall be included in
92+
all copies or substantial portions of the Software.
93+
94+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
95+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
96+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
97+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
98+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
99+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
100+
THE SOFTWARE.

0 commit comments

Comments
 (0)