removing features that tmux/screen handler better
This commit is contained in:
		
							parent
							
								
									7d13c20f5a
								
							
						
					
					
						commit
						828c9bbad4
					
				
							
								
								
									
										34
									
								
								README.rst
									
									
									
									
									
								
							
							
						
						
									
										34
									
								
								README.rst
									
									
									
									
									
								
							@ -1,41 +1,17 @@
 | 
				
			|||||||
A simple VTE-based terminal.
 | 
					A simple VTE-based terminal.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
The goal is a keyboard-centric terminal without GUI frills. Features will be
 | 
					Features that are available with ``tmux`` or ``screen`` such as tabs,
 | 
				
			||||||
configurable at compile-time (enable/disable) in ``config.h``, along with
 | 
					scrollback search/completion and keyboard url selection are left out.
 | 
				
			||||||
keybindings.
 | 
					
 | 
				
			||||||
 | 
					Configuration is done at compile-time via ``config.h``.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
DEPENDENCIES
 | 
					DEPENDENCIES
 | 
				
			||||||
============
 | 
					============
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Either vte (default) or vte3, including the vte dependencies.
 | 
					Either vte (default) or vte3. You can use vte3 by building with ``make GTK3=1``.
 | 
				
			||||||
 | 
					 | 
				
			||||||
You can use vte3 by building with ``make GTK3=1``.
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
KEYBINDINGS
 | 
					KEYBINDINGS
 | 
				
			||||||
===========
 | 
					===========
 | 
				
			||||||
 | 
					
 | 
				
			||||||
* ``ctrl-shift-c``: copy to CLIPBOARD
 | 
					* ``ctrl-shift-c``: copy to CLIPBOARD
 | 
				
			||||||
* ``ctrl-shift-v``: paste from CLIPBOARD
 | 
					* ``ctrl-shift-v``: paste from CLIPBOARD
 | 
				
			||||||
 | 
					 | 
				
			||||||
Scrollback search:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
* ``ctrl-/``: start forward search
 | 
					 | 
				
			||||||
* ``ctrl-?``: start backward search
 | 
					 | 
				
			||||||
* ``ctrl-shift-n``: search forward
 | 
					 | 
				
			||||||
* ``ctrl-shift-p``: search backward
 | 
					 | 
				
			||||||
* ``ctrl-shift-u``: start forward url search
 | 
					 | 
				
			||||||
* ``ctrl-shift-i``: start backward url search
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
While typing search pattern:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
* ``enter``: start search
 | 
					 | 
				
			||||||
* ``escape``: cancel search
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
TODO
 | 
					 | 
				
			||||||
====
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
* saner scrollback search widget
 | 
					 | 
				
			||||||
* better keyboard url selection/opening
 | 
					 | 
				
			||||||
* configurable keybindings
 | 
					 | 
				
			||||||
* ``ctrl-shift-n`` and ``ctrl-shift-p`` should be next/prev match in the
 | 
					 | 
				
			||||||
  direction of the current search, like ``n`` and ``N`` in vim.
 | 
					 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										94
									
								
								termite.c
									
									
									
									
									
								
							
							
						
						
									
										94
									
								
								termite.c
									
									
									
									
									
								
							@ -1,5 +1,3 @@
 | 
				
			|||||||
#include <stdbool.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <gtk/gtk.h>
 | 
					#include <gtk/gtk.h>
 | 
				
			||||||
#include <vte/vte.h>
 | 
					#include <vte/vte.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -11,75 +9,8 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "config.h"
 | 
					#include "config.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef __GNUC__
 | 
					static gboolean key_press_cb(GtkWidget *vte, GdkEventKey *event) {
 | 
				
			||||||
#  define  __attribute__(x)
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
enum search_direction {
 | 
					 | 
				
			||||||
    search_forward,
 | 
					 | 
				
			||||||
    search_backward
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
typedef struct search_dialog_info {
 | 
					 | 
				
			||||||
    GtkWidget *vte;
 | 
					 | 
				
			||||||
    GtkWidget *entry;
 | 
					 | 
				
			||||||
    enum search_direction direction;
 | 
					 | 
				
			||||||
    bool open;
 | 
					 | 
				
			||||||
} search_dialog_info;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static void search(VteTerminal *vte, const char *pattern, enum search_direction direction) {
 | 
					 | 
				
			||||||
    GRegex *regex = vte_terminal_search_get_gregex(vte);
 | 
					 | 
				
			||||||
    if (regex) g_regex_unref(regex);
 | 
					 | 
				
			||||||
    regex = g_regex_new(pattern, 0, 0, NULL);
 | 
					 | 
				
			||||||
    vte_terminal_search_set_gregex(vte, regex);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (direction == search_forward) {
 | 
					 | 
				
			||||||
        vte_terminal_search_find_next(vte);
 | 
					 | 
				
			||||||
    } else {
 | 
					 | 
				
			||||||
        vte_terminal_search_find_previous(vte);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static void search_response_cb(GtkDialog *dialog, gint response_id, search_dialog_info *info) {
 | 
					 | 
				
			||||||
    if (response_id == GTK_RESPONSE_ACCEPT) {
 | 
					 | 
				
			||||||
        search(VTE_TERMINAL(info->vte), gtk_entry_get_text(GTK_ENTRY(info->entry)), info->direction);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    gtk_widget_destroy(GTK_WIDGET(dialog));
 | 
					 | 
				
			||||||
    info->open = false;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static void open_search_dialog(GtkWidget *vte, enum search_direction direction, search_dialog_info *info) {
 | 
					 | 
				
			||||||
    info->direction = direction;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (info->open) {
 | 
					 | 
				
			||||||
        return;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    info->open = true;
 | 
					 | 
				
			||||||
    info->entry = gtk_entry_new();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    GtkWidget *dialog, *content_area;
 | 
					 | 
				
			||||||
    dialog = gtk_dialog_new_with_buttons("Search",
 | 
					 | 
				
			||||||
                                         GTK_WINDOW(gtk_widget_get_toplevel(vte)),
 | 
					 | 
				
			||||||
                                         GTK_DIALOG_DESTROY_WITH_PARENT,
 | 
					 | 
				
			||||||
                                         GTK_STOCK_OK,
 | 
					 | 
				
			||||||
                                         GTK_RESPONSE_ACCEPT,
 | 
					 | 
				
			||||||
                                         NULL);
 | 
					 | 
				
			||||||
    content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
 | 
					 | 
				
			||||||
    g_signal_connect(dialog, "response", G_CALLBACK(search_response_cb), info);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT);
 | 
					 | 
				
			||||||
    gtk_entry_set_activates_default(GTK_ENTRY(info->entry), TRUE);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    gtk_container_add(GTK_CONTAINER(content_area), info->entry);
 | 
					 | 
				
			||||||
    gtk_widget_show_all(dialog);
 | 
					 | 
				
			||||||
    gtk_widget_grab_focus(GTK_WIDGET(info->entry));
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static gboolean key_press_cb(GtkWidget *vte, GdkEventKey *event, search_dialog_info *info) {
 | 
					 | 
				
			||||||
    const GdkModifierType modifiers = event->state & gtk_accelerator_get_default_mod_mask();
 | 
					    const GdkModifierType modifiers = event->state & gtk_accelerator_get_default_mod_mask();
 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (modifiers == (GDK_CONTROL_MASK|GDK_SHIFT_MASK)) {
 | 
					    if (modifiers == (GDK_CONTROL_MASK|GDK_SHIFT_MASK)) {
 | 
				
			||||||
        switch (gdk_keyval_to_lower(event->keyval)) {
 | 
					        switch (gdk_keyval_to_lower(event->keyval)) {
 | 
				
			||||||
            case GDK_c:
 | 
					            case GDK_c:
 | 
				
			||||||
@ -88,27 +19,8 @@ static gboolean key_press_cb(GtkWidget *vte, GdkEventKey *event, search_dialog_i
 | 
				
			|||||||
            case GDK_v:
 | 
					            case GDK_v:
 | 
				
			||||||
                vte_terminal_paste_clipboard(VTE_TERMINAL(vte));
 | 
					                vte_terminal_paste_clipboard(VTE_TERMINAL(vte));
 | 
				
			||||||
                return TRUE;
 | 
					                return TRUE;
 | 
				
			||||||
            case GDK_p:
 | 
					 | 
				
			||||||
                vte_terminal_search_find_previous(VTE_TERMINAL(vte));
 | 
					 | 
				
			||||||
                return TRUE;
 | 
					 | 
				
			||||||
            case GDK_n:
 | 
					 | 
				
			||||||
                vte_terminal_search_find_next(VTE_TERMINAL(vte));
 | 
					 | 
				
			||||||
                return TRUE;
 | 
					 | 
				
			||||||
            case GDK_u:
 | 
					 | 
				
			||||||
                search(VTE_TERMINAL(vte), url_regex, search_forward);
 | 
					 | 
				
			||||||
                return TRUE;
 | 
					 | 
				
			||||||
            case GDK_i:
 | 
					 | 
				
			||||||
                search(VTE_TERMINAL(vte), url_regex, search_backward);
 | 
					 | 
				
			||||||
                return TRUE;
 | 
					 | 
				
			||||||
            case GDK_question:
 | 
					 | 
				
			||||||
                open_search_dialog(vte, search_backward, info);
 | 
					 | 
				
			||||||
                return TRUE;
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (modifiers == GDK_CONTROL_MASK && event->keyval == GDK_slash) {
 | 
					 | 
				
			||||||
        open_search_dialog(vte, search_forward, info);
 | 
					 | 
				
			||||||
        return TRUE;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    return FALSE;
 | 
					    return FALSE;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -246,11 +158,9 @@ int main(int argc, char **argv) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    vte_terminal_set_colors(VTE_TERMINAL(vte), &foreground, &background, palette, 16);
 | 
					    vte_terminal_set_colors(VTE_TERMINAL(vte), &foreground, &background, palette, 16);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    search_dialog_info info = { .vte = vte, .open = false };
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL);
 | 
					    g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL);
 | 
				
			||||||
    g_signal_connect(vte, "button-press-event", G_CALLBACK(button_press_cb), NULL);
 | 
					    g_signal_connect(vte, "button-press-event", G_CALLBACK(button_press_cb), NULL);
 | 
				
			||||||
    g_signal_connect(vte, "key-press-event", G_CALLBACK(key_press_cb), &info);
 | 
					    g_signal_connect(vte, "key-press-event", G_CALLBACK(key_press_cb), NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef URGENT_ON_BEEP
 | 
					#ifdef URGENT_ON_BEEP
 | 
				
			||||||
    if (g_signal_lookup("beep", G_TYPE_FROM_INSTANCE(G_OBJECT(vte)))) {
 | 
					    if (g_signal_lookup("beep", G_TYPE_FROM_INSTANCE(G_OBJECT(vte)))) {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user