aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--PKGBUILD21
-rw-r--r--src/Makefile32
-rw-r--r--src/T.c171
-rw-r--r--src/T.desktop163
-rw-r--r--src/config.def.h48
-rw-r--r--src/config.h48
6 files changed, 483 insertions, 0 deletions
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 0000000..8e1b835
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,21 @@
+# Maintainer: Samuel Fadel <samuelfadel at DOMAIN> (DOMAIN is gmail dot com)
+
+pkgname=T
+pkgver=0.5
+pkgrel=1
+pkgdesc="Lean Terminal emulator"
+arch=('i686' 'x86_64')
+license=('GPL')
+depends=('gtk2' 'vte')
+source=("http://domain.tld/${pkgname}-${pkgver}.tar.bz2")
+sha1sums=('b0ff968aafa6e1c8ef1f331224171c0b52d3e08d')
+
+build() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ make
+}
+
+package() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ make DESTDIR=${pkgdir} install
+}
diff --git a/src/Makefile b/src/Makefile
new file mode 100644
index 0000000..64da6b3
--- /dev/null
+++ b/src/Makefile
@@ -0,0 +1,32 @@
+PREFIX = /usr
+
+INCS = `pkg-config --cflags gtk+-2.0 vte`
+LIBS = `pkg-config --libs gtk+-2.0 vte`
+CFLAGS = -ansi -pedantic -Wall -O3 ${INCS}
+LDFLAGS = -s ${LIBS}
+CC = cc
+
+SRC = T.c
+OBJ = ${SRC:.c=.o}
+
+all: T
+
+.c.o:
+ @echo CC $<
+ @${CC} -c ${CFLAGS} $<
+
+${OBJ}: config.h
+
+T: ${OBJ}
+ @echo CC -o $@
+ @${CC} -o $@ ${OBJ} ${LDFLAGS}
+
+clean:
+ @echo cleaning
+ @rm -rf T ${OBJ}
+
+install: all
+ @echo installing executable file to ${DESTDIR}${PREFIX}/bin
+ @install -D -m755 T ${DESTDIR}${PREFIX}/bin/T
+ @echo installing icon to ${DESTDIR}${PREFIX}/share/applications
+ @install -D -m644 T.desktop ${DESTDIR}${PREFIX}/share/applications/T.desktop
diff --git a/src/T.c b/src/T.c
new file mode 100644
index 0000000..be82b32
--- /dev/null
+++ b/src/T.c
@@ -0,0 +1,171 @@
+/*
+ * T.c
+ *
+ * T is a lean Terminal emulator.
+ */
+
+#include <gdk/gdk.h>
+#include <gdk/gdkkeysyms.h>
+#include <gtk/gtk.h>
+#include <unistd.h>
+#include <vte/vte.h>
+
+#include "config.h"
+
+static GtkWindow *main_window;
+
+/* Event callbacks */
+static gboolean window_delete_event_callback(GtkWidget *widget, GdkEvent *event, gpointer data);
+static void window_destroy_callback(GtkWidget *widget, gpointer data);
+static void terminal_child_exited_callback(VteTerminal *terminal, gpointer data);
+static void terminal_window_title_changed_callback(VteTerminal *terminal, gpointer data);
+
+/* Helper setup functions */
+static void setup_pty(VteTerminal *terminal, GPid *child_pid);
+static void set_app_preferences(VteTerminal *terminal);
+static void setup_terminal(VteTerminal *terminal);
+static void setup_main_window(void);
+
+static gboolean
+window_delete_event_callback(GtkWidget *widget, GdkEvent *event, gpointer data)
+{
+ /* TODO: always false? */
+ return FALSE;
+}
+
+static void
+window_destroy_callback(GtkWidget *widget, gpointer data)
+{
+ gtk_main_quit();
+}
+
+static gboolean
+terminal_key_press_callback(GtkWidget *widget, GdkEvent *event, gpointer data)
+{
+ GdkEventKey *key_event = (GdkEventKey *) event;
+ VteTerminal *terminal = (VteTerminal *) widget;
+
+ if ((key_event->state & GDK_SHIFT_MASK) == 0
+ || (key_event->state & GDK_CONTROL_MASK) == 0)
+ return FALSE;
+
+ switch (key_event->keyval) {
+ case GDK_KEY_C:
+ case GDK_KEY_c:
+ vte_terminal_copy_clipboard(terminal);
+ break;
+ case GDK_KEY_V:
+ case GDK_KEY_v:
+ vte_terminal_paste_clipboard(terminal);
+ break;
+ case GDK_KEY_N:
+ case GDK_KEY_n:
+ fork();
+ break;
+ }
+
+ return TRUE;
+}
+
+static void
+terminal_child_exited_callback(VteTerminal *terminal, gpointer data)
+{
+ gtk_main_quit();
+}
+
+static void
+terminal_window_title_changed_callback(VteTerminal *terminal, gpointer data)
+{
+ gtk_window_set_title(main_window, vte_terminal_get_window_title(terminal));
+}
+
+static void
+setup_pty(VteTerminal *terminal, GPid *child_pid)
+{
+ VtePty* pty;
+ char *argv[] = { NULL, NULL };
+
+ /* TODO: error handling */
+ argv[0] = vte_get_user_shell();
+ pty = vte_terminal_pty_new(terminal, VTE_PTY_DEFAULT, NULL);
+ vte_terminal_set_pty_object(terminal, pty);
+ vte_terminal_fork_command_full(terminal, VTE_PTY_DEFAULT, ".", argv, NULL, G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, child_pid, NULL);
+}
+
+static void
+set_app_preferences(VteTerminal *terminal)
+{
+ /*
+ * WARNING:
+ * Options set here can be configured through config.h
+ */
+
+ int i;
+ GdkColor palette[PALETTE_SIZE], bg_color, fg_color;
+
+ /* Set preferences */
+ vte_terminal_set_mouse_autohide(terminal, MOUSE_AUTOHIDE);
+ vte_terminal_set_visible_bell(terminal, VISIBLE_BELL);
+ vte_terminal_set_audible_bell(terminal, AUDIBLE_BELL);
+ vte_terminal_set_font_from_string(terminal, FONT_NAME);
+
+ gdk_color_parse(FOREGROUND_COLOR, &fg_color);
+ gdk_color_parse(BACKGROUND_COLOR, &bg_color);
+ for (i = 0; i < PALETTE_SIZE; ++i)
+ gdk_color_parse(COLOR_PALETTE[i], &palette[i]);
+ vte_terminal_set_colors(terminal, &fg_color, &bg_color, palette, PALETTE_SIZE);
+}
+
+static void
+setup_terminal(VteTerminal *terminal)
+{
+ GPid child_pid;
+
+ setup_pty(terminal, &child_pid);
+ vte_terminal_watch_child(terminal, child_pid);
+
+ g_signal_connect(terminal, "child-exited", G_CALLBACK(terminal_child_exited_callback), NULL);
+ g_signal_connect(terminal, "window-title-changed", G_CALLBACK(terminal_window_title_changed_callback), NULL);
+ g_signal_connect(terminal, "key-press-event", G_CALLBACK(terminal_key_press_callback), NULL);
+
+ set_app_preferences(terminal);
+}
+
+static void
+setup_main_window(void)
+{
+ GdkGeometry hints;
+ VteTerminal *terminal;
+
+ terminal = (VteTerminal *) vte_terminal_new();
+ setup_terminal(terminal);
+
+ hints.base_width = vte_terminal_get_char_width(terminal);
+ hints.base_height = vte_terminal_get_char_height(terminal);
+ hints.min_width = hints.base_width * MIN_WIDTH;
+ hints.min_height = hints.base_height * MIN_HEIGHT;
+ hints.width_inc = hints.base_width;
+ hints.height_inc = hints.base_height;
+ gtk_window_set_geometry_hints(main_window, GTK_WIDGET(terminal), &hints, GDK_HINT_RESIZE_INC | GDK_HINT_MIN_SIZE | GDK_HINT_BASE_SIZE);
+
+ g_signal_connect(main_window, "delete-event", G_CALLBACK(window_delete_event_callback), NULL);
+ g_signal_connect(main_window, "destroy", G_CALLBACK(window_destroy_callback), NULL);
+ gtk_window_set_icon_name(main_window, "utilities-terminal");
+
+ gtk_container_add(GTK_CONTAINER(main_window), GTK_WIDGET(terminal));
+
+ gtk_widget_show(GTK_WIDGET(terminal));
+ gtk_widget_show(GTK_WIDGET(main_window));
+}
+
+int
+main(int argc, char *argv[])
+{
+ gtk_init(&argc, &argv);
+
+ main_window = (GtkWindow *) gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ setup_main_window();
+ gtk_main();
+
+ return 0;
+}
diff --git a/src/T.desktop b/src/T.desktop
new file mode 100644
index 0000000..cfdd139
--- /dev/null
+++ b/src/T.desktop
@@ -0,0 +1,163 @@
+[Desktop Entry]
+Encoding=UTF-8
+Name=T
+Name[af]=T
+Name[ar]=T
+Name[be]=T
+Name[bg]=T
+Name[bn]=T
+Name[bn_IN]=T
+Name[ca]=T
+Name[cs]=T
+Name[da]=T
+Name[de]=T
+Name[el]=T
+Name[en_GB]=T
+Name[es]=T
+Name[es_VE]=T
+Name[et]=T
+Name[eu]=T
+Name[fa]=T
+Name[fi]=T
+Name[fo]=T
+Name[fr]=T
+Name[frp]=T
+Name[gl]=T
+Name[he]=T
+Name[hr]=T
+Name[hu]=T
+Name[id]=T
+Name[it]=T
+Name[ja]=T
+Name[lg]=T
+Name[lt]=T
+Name[ms]=T
+Name[nb]=T
+Name[nl]=T
+Name[nn]=T
+Name[pl]=T
+Name[pt]=T
+Name[pt_BR]=T
+Name[ro]=T
+Name[ru]=T
+Name[sk]=T
+Name[sl]=T
+Name[sr]=T
+Name[sr@latin]=T
+Name[sv]=T
+Name[te]=T
+Name[tr]=T
+Name[tt_RU]=T
+Name[uk]=т
+Name[ur]=T
+Name[ur_PK]=T
+Name[vi]=T
+Name[zh_CN]=T
+Name[zh_TW]=T
+GenericName=Terminal
+GenericName[af]=Terminaal
+GenericName[ar]=شاشة طرفية
+GenericName[be]=Тэрмінал
+GenericName[bg]=Терминал
+GenericName[bn]=টার্মিনাল
+GenericName[ca]=Terminal
+GenericName[cs]=Terminál
+GenericName[da]=Terminal
+GenericName[de]=Terminal
+GenericName[el]=Τερματικό
+GenericName[en_GB]=Terminal
+GenericName[es]=Terminal
+GenericName[es_VE]=Terminal
+GenericName[et]=Terminal
+GenericName[eu]=Terminala
+GenericName[fa]=پایانه
+GenericName[fi]=Pääte
+GenericName[fo]=Útstøð
+GenericName[fr]=Terminal
+GenericName[gl]=Terminal
+GenericName[he]=מסוף
+GenericName[hr]=Terminal
+GenericName[hu]=Terminál
+GenericName[id]=Terminal
+GenericName[it]=Terminale
+GenericName[ja]=端末
+GenericName[ko]=터미널
+GenericName[lg]=Kiwandikiro
+GenericName[lt]=Terminalas
+GenericName[ml]=ടെ‍ര്മിനല്
+GenericName[ms]=Terminal
+GenericName[nb]=Terminal
+GenericName[nl]=Terminalvenster
+GenericName[nn]=Terminal
+GenericName[pl]=Terminal
+GenericName[pt]=Terminal
+GenericName[pt_BR]=Terminal
+GenericName[ro]=Terminal
+GenericName[ru]=Терминал
+GenericName[sk]=Terminál
+GenericName[sl]=Terminal
+GenericName[sr]=Терминал
+GenericName[sr@latin]=Terminal
+GenericName[sv]=Terminal
+GenericName[te]=టెర్మినల్
+GenericName[tr]=Uçbirim
+GenericName[tt_RU]=Терминал
+GenericName[uk]=Термінал
+GenericName[vi]=Cửa sổ lệnh
+GenericName[zh_CN]=终端
+GenericName[zh_TW]=終端機
+Comment=Use the command line
+Comment[af]=Gebruik die opdraglyn
+Comment[ar]=استخدِم سطر الأوامر
+Comment[be]=Выкарыстоўваць загадны радок
+Comment[bg]=Използване на команден ред
+Comment[bn]=কমান্ড লাইন ব্যবহার করা হবে
+Comment[ca]=Utilitza la línia d'ordres
+Comment[cs]=Používat příkazový řádek
+Comment[da]=Brug kommandolinjen
+Comment[de]=Befehlszeile verwenden
+Comment[el]=Χρήση γραμμής εντολών
+Comment[en_GB]=Use the command line
+Comment[es]=Usar la línea de comandos
+Comment[es_VE]=Usar la línea de comandos
+Comment[et]=Käsurea kasutamine
+Comment[eu]=Erabili komando-lerroa
+Comment[fa]=استفاده از خط فرمان
+Comment[fi]=Käytä komentoriviä
+Comment[fo]=Nýt stýriboðslinjuna
+Comment[fr]=Utiliser la ligne de commande
+Comment[gl]=Usar a liña de ordes
+Comment[he]=שימוש בשורת הפקודה
+Comment[hr]=Koristi naredbeni redak
+Comment[hu]=Parancssor használata
+Comment[id]=Gunakan perintah baris
+Comment[it]=Usa la riga di comando
+Comment[ja]=コマンド・ライン端末です
+Comment[ko]=명령 행을 사용합니다
+Comment[lg]=Kolera mu kiwandikiro
+Comment[lt]=Naudoti komandų eilutę
+Comment[nb]=Bruk kommandolinjen
+Comment[nl]=Gebruik de opdrachtregel
+Comment[nn]=Bruk kommandolinja
+Comment[pl]=Emulator terminala
+Comment[pt]=Utilizar a linha de comando
+Comment[pt_BR]=Use a linha de comando
+Comment[ro]=Folosește linia de comandă
+Comment[ru]=Использовать командную строку
+Comment[sk]=Použiť príkazový riadok
+Comment[sl]=Uporabi ukazno vrstico
+Comment[sr]=Користите линију наредби
+Comment[sr@latin]=Koristite liniju naredbi
+Comment[sv]=Använd kommandoraden
+Comment[te]=కమాండు లైనును వాడు
+Comment[tr]=Komut satırını kullan
+Comment[tt_RU]=Команда юлын куллану
+Comment[uk]=Використати командну стрічку
+Comment[vi]=Dùng dòng lệnh
+Comment[zh_CN]=使用命令行
+Comment[zh_TW]=使用命令列
+TryExec=T
+Exec=T
+Type=Application
+Icon=utilities-terminal
+Categories=GTK;Utility;TerminalEmulator;
diff --git a/src/config.def.h b/src/config.def.h
new file mode 100644
index 0000000..55b1cce
--- /dev/null
+++ b/src/config.def.h
@@ -0,0 +1,48 @@
+/*
+ * config.h
+ *
+ * Configuration file. Modify these to customize T.
+ */
+
+/* Minimum width/height, in characters */
+#define MIN_WIDTH 20
+#define MIN_HEIGHT 5
+
+/* Font name */
+#define FONT_NAME "Monospace 9"
+
+/* Color palette definition */
+/* PALETTE_SIZE must be 8, 16, 24 or between 25 and 255, inclusive */
+#define PALETTE_SIZE 16
+
+static const char *COLOR_PALETTE[PALETTE_SIZE] = {
+ "#000000", /* 0 Black */
+ "#a5372e", /* 1 Red */
+ "#4a663c", /* 2 Green */
+ "#7c5618", /* 3 Yellow */
+ "#566060", /* 4 Blue */
+ "#8e4948", /* 5 Magenta */
+ "#6d5b42", /* 6 Cyan */
+ "#8d8d8d", /* 7 White */
+ "#2b2b2b", /* 8 Black */
+ "#e06c5c", /* 9 Red */
+ "#7b996c", /* 10 Green */
+ "#b38849", /* 11 Yellow */
+ "#889393", /* 12 Blue */
+ "#c67c78", /* 13 Magenta */
+ "#a28d73", /* 14 Cyan */
+ "#c6c6c6", /* 15 White */
+};
+
+/* Foreground and background. */
+#define FOREGROUND_COLOR "#757575" /* COLOR_PALETTE[7] */
+#define BACKGROUND_COLOR "#151515" /* COLOR_PALETTE[0] */
+
+/* Mouse auto-hide (TRUE or FALSE) */
+#define MOUSE_AUTOHIDE TRUE
+
+/* Visible bell (TRUE or FALSE) */
+#define VISIBLE_BELL FALSE
+
+/* Audible bell (TRUE or FALSE) */
+#define AUDIBLE_BELL FALSE
diff --git a/src/config.h b/src/config.h
new file mode 100644
index 0000000..ae9458f
--- /dev/null
+++ b/src/config.h
@@ -0,0 +1,48 @@
+/*
+ * config.h
+ *
+ * Configuration file. Modify these to customize T.
+ */
+
+/* Minimum width/height, in characters */
+#define MIN_WIDTH 20
+#define MIN_HEIGHT 5
+
+/* Font name */
+#define FONT_NAME "Terminus 9"
+
+/* Color palette definition */
+/* PALETTE_SIZE must be 8, 16, 24 or between 25 and 255, inclusive */
+#define PALETTE_SIZE 16
+
+static const char *COLOR_PALETTE[PALETTE_SIZE] = {
+ "#000000", /* 0 Black */
+ "#a5372e", /* 1 Red */
+ "#4a663c", /* 2 Green */
+ "#7c5618", /* 3 Yellow */
+ "#566060", /* 4 Blue */
+ "#8e4948", /* 5 Magenta */
+ "#6d5b42", /* 6 Cyan */
+ "#8d8d8d", /* 7 White */
+ "#2b2b2b", /* 8 Black */
+ "#e06c5c", /* 9 Red */
+ "#7b996c", /* 10 Green */
+ "#b38849", /* 11 Yellow */
+ "#889393", /* 12 Blue */
+ "#c67c78", /* 13 Magenta */
+ "#a28d73", /* 14 Cyan */
+ "#c6c6c6", /* 15 White */
+};
+
+/* Foreground and background. */
+#define FOREGROUND_COLOR "#757575" /* COLOR_PALETTE[7] */
+#define BACKGROUND_COLOR "#151515" /* COLOR_PALETTE[0] */
+
+/* Mouse auto-hide (TRUE or FALSE) */
+#define MOUSE_AUTOHIDE TRUE
+
+/* Visible bell (TRUE or FALSE) */
+#define VISIBLE_BELL FALSE
+
+/* Audible bell (TRUE or FALSE) */
+#define AUDIBLE_BELL FALSE