Skip to content
This repository was archived by the owner on Aug 15, 2019. It is now read-only.
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,21 @@ LUA_OPT=generic
override CFLAGS+=-Werror -Wall -g -fPIC -O2 -DNDEBUG -ftrapv -Wfloat-equal -Wundef -Wwrite-strings -Wuninitialized -pedantic -std=c11

OS := $(shell uname)
DE := $(shell echo $(DESKTOP_SESSION))

ifeq ($(OS),$(filter $(OS), FreeBSD OpenBSD NetBSD))
CADDFLAG := -lexecinfo
CADDFLAG += -lexecinfo
endif

ifeq ($(DE),gnome)
CADDFLAG += `pkg-config --libs --cflags gtk+-3.0` `pkg-config --libs gtk+-3.0`
DE_FLAG := -Dgnome
endif

all: main.c syntax
$(info DE is $(DE))
mkdir -p $(BUILDDIR)
$(CC) $(MAIN) $(SOURCES) -DSTXDIR=\"$(STXDIR)\" -o $(BUILDDIR)$(TARGET) $(CFLAGS) $(CADDFLAG)
$(CC) $(MAIN) $(SOURCES) -DSTXDIR=\"$(STXDIR)\" -o $(BUILDDIR)$(TARGET) $(CFLAGS) $(CADDFLAG) $(DE_FLAG)

lua:
cd ./vendor/lua-5.3.4/src && make clean && make $(LUA_OPT)
Expand Down
12 changes: 11 additions & 1 deletion main.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#include <signal.h>
#include <execinfo.h>
#include "src/editor.h"
#ifdef __unix__
#ifdef gnome
#include <gtk/gtk.h>
#endif
#endif

#define STRINGIFY2(X) #X
#define STRINGIFY(X) STRINGIFY2(X)
Expand Down Expand Up @@ -34,8 +39,13 @@ void exitf() {
#endif
}


int main(int argc, char** argv) {
#ifdef __unix__
#ifdef gnome
gtk_init(&argc, &argv);
#endif
#endif

stx = syntax_init((char*) STXDIR);
GLOB = e_setup();

Expand Down
16 changes: 15 additions & 1 deletion src/clipboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,26 @@ char* e_clipboard_paste() {
return buffer;
}

#elif __unix__
#ifdef gnome
#include <gtk/gtk.h>
GtkClipboard *clipboard;
void e_clipboard_copy(char* str){
clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY);
gchar *clip_str = str;
gtk_clipboard_set_text(clipboard, clip_str, -1);
}

char* e_clipboard_paste(){
clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY);
return (char*)gtk_clipboard_wait_for_text(clipboard);
}
#endif
#else

void e_clipboard_copy(char* str) {}

char* e_clipboard_paste() {
return NULL;
}

#endif