From 8531f4c74274b8aa99168d220738227557a9c418 Mon Sep 17 00:00:00 2001 From: dos-reis Date: Fri, 7 Mar 2008 15:19:01 +0000 Subject: * hyper/: De-pamphletize. --- src/hyper/keyin.c | 286 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 286 insertions(+) create mode 100644 src/hyper/keyin.c (limited to 'src/hyper/keyin.c') diff --git a/src/hyper/keyin.c b/src/hyper/keyin.c new file mode 100644 index 00000000..b6d2004e --- /dev/null +++ b/src/hyper/keyin.c @@ -0,0 +1,286 @@ +/* + Copyright (C) 1991-2002, The Numerical Algorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical Algorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/****************************************************************************** + * + * keyin.c: + * + * Copyright The Numerical Algorithms Group Limited 1991, 1992, 1993. + * + ****************************************************************************/ +#define _KEYIN_C +#include "axiom-c-macros.h" +#include "useproto.h" +#include "debug.h" + + +#include "hyper.h" +#include "keyin.h" +#include "event.h" +#include "parse.h" +#include "scrollbar.h" + +#include "all_hyper_proto.H1" +#include + + +#define min(x,y) ( (xxkey.state & ShiftMask) { + name = gWindow->page->name; + filename = gWindow->page->filename; + sprintf(buffer, "htadd -l %s\n", filename); + system(buffer); + filehandle = (FILE *) hash_find(&gFileHashTable, filename); + fclose(filehandle); + hash_delete(&gFileHashTable, filename); + gWindow->fMacroHashTable = + (HashTable *) halloc(sizeof(HashTable), "macro hash"); + hash_init( + gWindow->fMacroHashTable, + MacroHashSize, + (EqualFunction ) string_equal, + (HashcodeFunction) string_hash); + gWindow->fPatchHashTable = (HashTable *) halloc(sizeof(HashTable), "patch hash"); + hash_init( + gWindow->fPatchHashTable, + PatchHashSize, + (EqualFunction ) string_equal, + (HashcodeFunction) string_hash); + gWindow->fPasteHashTable = (HashTable *) halloc(sizeof(HashTable), "paste hash"); + hash_init(gWindow->fPasteHashTable, + PasteHashSize, + (EqualFunction ) string_equal, + (HashcodeFunction) string_hash); + gWindow->fCondHashTable = (HashTable *) halloc(sizeof(HashTable), "cond hash"); + hash_init( + gWindow->fCondHashTable, + CondHashSize, + (EqualFunction ) string_equal, + (HashcodeFunction) string_hash); + gWindow->fPageHashTable = (HashTable *) halloc(sizeof(HashTable), "page hash"); + hash_init( + gWindow->fPageHashTable, + PageHashSize, + (EqualFunction ) string_equal, + (HashcodeFunction) string_hash); + make_special_pages(gWindow->fPageHashTable); + read_ht_db( + gWindow->fPageHashTable, + gWindow->fMacroHashTable, + gWindow->fPatchHashTable); + gWindow->page = (HyperDocPage *) hash_find(gWindow->fPageHashTable, name); + if (gWindow->page == NULL) { + fprintf(stderr, "lose...gWindow->page for %s is null\n", name); + exit(-1); + } + display_again = 1; + } + break; + case XK_F9: + make_window_link(KeyDefsHelpPage); + break; + case XK_Tab: + if (event->xkey.state & ShiftMask) + prev_input_focus(); + else if (event->xkey.state & ModifiersMask) + BeepAtTheUser(); + else + next_input_focus(); + break; + case XK_Return: + if (!(event->xkey.state & ShiftMask)) { + next_input_focus(); + break; + } + + /* next ones fall through to input area handling */ + + case XK_Escape: + if (!gWindow->page->current_item) + break; + case XK_F1: + if (!gWindow->page->current_item) { + gWindow->page->helppage = alloc_string(NoMoreHelpPage); + helpForHyperDoc(); + break; + } + case XK_Home: + if (!gWindow->page->current_item) { + scrollToFirstPage(); + break; + } + case XK_Up: + if (!gWindow->page->current_item) { + scrollUp(); + break; + } + case XK_Down: + if (!gWindow->page->current_item) { + scrollDown(); + break; + } + + default: + display_again = 0; + dialog(event, keysym, key_buffer); + XFlush(gXDisplay); + break; + } + + if (display_again) { + display_page(gWindow->page); + gWindow->fWindowHashTable = gWindow->page->fLinkHashTable; + } +} + + +/* + * This routine initializes some of the variables needed by the input + * strings, and boxes. + */ + +void +init_keyin(void) +{ + char *prop; + + /* + * First set all the values for when the active cursor is in the window + */ + + in_cursor_height = 2; + in_cursor_y = gInputFont->max_bounds.ascent + + gInputFont->max_bounds.descent; + in_cursor_width = gInputFont->max_bounds.width; + + /* + * Now for when the cursor is empty + */ + + out_cursor_height = gInputFont->max_bounds.ascent + + gInputFont->max_bounds.descent; + out_cursor_y = 2; + out_cursor_width = in_cursor_width; + + start_x = 5; + + start_y = gInputFont->max_bounds.ascent; + + /* + * Find out How big I should make the simple boxes + */ + + simple_box_width = XTextWidth(gInputFont, "X", 1) + 5; + + prop = XGetDefault(gXDisplay, gArgv[0], "ProtectedQuit"); + + if (prop == NULL) { + protected_quit = (char *) halloc(strlen("ProtectedPage") + 1, + "protected_quit"); + strcpy(protected_quit, "ProtectedPage"); + } + else { + protected_quit = (char *) halloc(strlen(prop) + 1, "protected_quit"); + strcpy(protected_quit, prop); + } + + +} -- cgit v1.2.3