コード例 #1
0
ファイル: syswin.c プロジェクト: BPaden/garglk
void winclipreceive(void)
{
    HGLOBAL rmem;
    wchar_t *rptr;
    int i, rlen;

    if(OpenClipboard(NULL)) {
        rmem = GetClipboardData(CF_UNICODETEXT);
        if (rmem && (rptr = GlobalLock(rmem))) {
            rlen = GlobalSize(rmem) / sizeof(wchar_t);
            for (i=0; i < rlen; i++) {
                if (rptr[i] == '\0')
                    break;
                else if (rptr[i] == '\r' || rptr[i] == '\n')
                    continue;
                else if (rptr[i] == '\b' || rptr[i] == '\t')
                    continue;
                else if (rptr[i] != 27)
                    gli_input_handle_key(rptr[i]);
            }
            GlobalUnlock(rmem);
        }
        CloseClipboard(); 
    }
}
コード例 #2
0
ファイル: syseoi.c プロジェクト: c4rlo/gargoyle-fedora
static void delete_char(vk_info_t *info)   { gli_input_handle_key(keycode_Delete); }
コード例 #3
0
ファイル: syseoi.c プロジェクト: c4rlo/gargoyle-fedora
static void new_line(vk_info_t *info)      { gli_input_handle_key(keycode_Return); }
コード例 #4
0
ファイル: syseoi.c プロジェクト: c4rlo/gargoyle-fedora
static void page_down(vk_info_t *info)     { gli_input_handle_key(keycode_PageDown); }
コード例 #5
0
ファイル: syseoi.c プロジェクト: c4rlo/gargoyle-fedora
static void page_up(vk_info_t *info)       { gli_input_handle_key(keycode_PageUp); }
コード例 #6
0
ファイル: syseoi.c プロジェクト: c4rlo/gargoyle-fedora
static void history_next(vk_info_t *info)  { gli_input_handle_key(keycode_Down); }
コード例 #7
0
ファイル: syseoi.c プロジェクト: c4rlo/gargoyle-fedora
static void history_prev(vk_info_t *info)  { gli_input_handle_key(keycode_Up); }
コード例 #8
0
ファイル: syseoi.c プロジェクト: c4rlo/gargoyle-fedora
static void cursor_right(vk_info_t *info)  { gli_input_handle_key(keycode_Right); }
コード例 #9
0
ファイル: syseoi.c プロジェクト: c4rlo/gargoyle-fedora
static void cursor_left(vk_info_t *info)   { gli_input_handle_key(keycode_Left); }
コード例 #10
0
ファイル: gtevent.c プロジェクト: ChadMcKinney/Entropy
void glk_select(event_t *event)
{
    int needrefresh = TRUE;
    
    curevent = event;
    gli_event_clearevent(curevent);
    
    gli_windows_update();
    gli_windows_set_paging(FALSE);
    gli_input_guess_focus();
    
    while (curevent->type == evtype_None) {
        int key;
    
        /* It would be nice to display a "hit any key to continue" message in
            all windows which require it. */
        if (needrefresh) {
            gli_windows_place_cursor();
            refresh();
            needrefresh = FALSE;
        }
        key = getch();
        
#ifdef OPT_USE_SIGNALS
        if (just_killed) {
            /* Someone hit ctrl-C. This flag is set by the
                SIGINT / SIGHUP signal handlers.*/
            gli_fast_exit();
        }
#endif /* OPT_USE_SIGNALS */
        
        if (key != ERR) {
            /* An actual key has been hit */
            gli_input_handle_key(key);
            needrefresh = TRUE;
            continue;
        }

        /* key == ERR; it's an idle event */
        
#ifdef OPT_USE_SIGNALS

        /* Check to see if the program has just resumed. This 
            flag is set by the SIGCONT signal handler. */
        if (just_resumed) {
            just_resumed = FALSE;
            gli_set_halfdelay();
            needrefresh = TRUE;
            continue;
        }

#ifdef OPT_WINCHANGED_SIGNAL
        /* Check to see if the screen-size has changed. The 
            screen_size_changed flag is set by the SIGWINCH signal
            handler. */
        if (screen_size_changed) {
            screen_size_changed = FALSE;
            gli_windows_size_change();
            needrefresh = TRUE;
            continue;
        }
#endif /* OPT_WINCHANGED_SIGNAL */

#endif /* OPT_USE_SIGNALS */

#ifdef OPT_TIMED_INPUT
        /* Check to see if we've passed next_time. */
        if (timing_msec) {
            struct timeval tv;
            gettimeofday(&tv, NULL);
            if (tv.tv_sec > next_time.tv_sec
                || (tv.tv_sec == next_time.tv_sec &&
                    tv.tv_usec > next_time.tv_usec)) {
                next_time = tv;
                add_millisec_to_time(&next_time, timing_msec);
                gli_event_store(evtype_Timer, NULL, 0, 0);
                continue;
            }
        }
#endif /* OPT_TIMED_INPUT */

    }
    
    /* An event has occurred; glk_select() is over. */
    gli_windows_trim_buffers();
    curevent = NULL;
}
コード例 #11
0
ファイル: syswin.c プロジェクト: BPaden/garglk
LRESULT CALLBACK
viewproc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    int x = (signed short) LOWORD(lParam);
    int y = (signed short) HIWORD(lParam);
    glui32 key;

    switch (message)
    {
    case WM_ERASEBKGND:
    return 1; // don't erase; we'll repaint it all

    case WM_PAINT:
    {
        PAINTSTRUCT ps;

        /* make sure we have a fresh bitmap */
        if (!gli_drawselect)
            gli_windows_redraw();
        else
            gli_drawselect = FALSE;

        /* and blit it to the screen */
        hdc = BeginPaint(hwnd, &ps);
        winblit(ps.rcPaint);
        hdc = NULL;
        EndPaint(hwnd, &ps);

        return 0;
    }

    case WM_SIZE:
    {
        int newwid = LOWORD(lParam);
        int newhgt = HIWORD(lParam);

        if (newwid == 0 || newhgt == 0)
        break;

        if (newwid == gli_image_w && newhgt == gli_image_h)
        break;

        gli_image_w = newwid;
        gli_image_h = newhgt;

        gli_resize_mask(gli_image_w, gli_image_h);

        gli_image_s = ((gli_image_w * 3 + 3) / 4) * 4;
        if (gli_image_rgb)
        free(gli_image_rgb);
        gli_image_rgb = malloc(gli_image_s * gli_image_h);

        gli_force_redraw = 1;

        gli_windows_size_change();

        break;
    }

    case WM_LBUTTONDOWN:
    {
        SetFocus(hwndview);
        gli_input_handle_click(x, y);
        return 0;
    }

    case WM_LBUTTONUP:
    {
        gli_copyselect = FALSE;
        SetCursor(idc_arrow);
        return 0;
    }

    case WM_MBUTTONDOWN:
    case WM_RBUTTONDOWN:
    {
        SetFocus(hwndview);
        return 0;
    }

    case WM_MOUSEWHEEL:
    {
        if (GET_WHEEL_DELTA_WPARAM(wParam) > 0)
            gli_input_handle_key(keycode_MouseWheelUp);
        else
            gli_input_handle_key(keycode_MouseWheelDown);
    }

    case WM_CAPTURECHANGED:
    {
        gli_copyselect = FALSE;
        return 0;
    }

    case WM_MOUSEMOVE:
    {
        /* catch and release */
        RECT rect;
        POINT pt = { x, y };
        GetClientRect(hwnd, &rect);
        int hover = PtInRect(&rect, pt);

        if (!hover) {
            if (GetCapture() == hwnd)
                ReleaseCapture();
        } else {
            if (GetCapture() != hwnd ) {
                SetCapture(hwnd);
            }
            if (gli_copyselect) {
                SetCursor(idc_ibeam);
                gli_move_selection(x, y);
            } else {
                if (gli_get_hyperlink(x, y)) {
                    SetCursor(idc_hand);
                } else {
                    SetCursor(idc_arrow);
                }
            }
        }

        return 0;
    }

    case WM_COPY:
    {
        gli_copyselect = FALSE;
        SetCursor(idc_arrow);
        winclipsend();
        return 0;
    }

    case WM_PASTE:
    {
        SetFocus(hwndview);
        winclipreceive();
        return 0;
    }

    case WM_KEYDOWN:

    switch (wParam)
    {
    case VK_PRIOR: gli_input_handle_key(keycode_PageUp); break;
    case VK_NEXT: gli_input_handle_key(keycode_PageDown); break;
    case VK_HOME: gli_input_handle_key(keycode_Home); break;
    case VK_END: gli_input_handle_key(keycode_End); break;
    case VK_LEFT: gli_input_handle_key(keycode_Left); break;
    case VK_RIGHT: gli_input_handle_key(keycode_Right); break;
    case VK_UP: gli_input_handle_key(keycode_Up); break;
    case VK_DOWN: gli_input_handle_key(keycode_Down); break;
    case VK_ESCAPE: gli_input_handle_key(keycode_Escape); break;
    case VK_DELETE: gli_input_handle_key(keycode_Erase); break;
    case VK_F1: gli_input_handle_key(keycode_Func1); break;
    case VK_F2: gli_input_handle_key(keycode_Func2); break;
    case VK_F3: gli_input_handle_key(keycode_Func3); break;
    case VK_F4: gli_input_handle_key(keycode_Func4); break;
    case VK_F5: gli_input_handle_key(keycode_Func5); break;
    case VK_F6: gli_input_handle_key(keycode_Func6); break;
    case VK_F7: gli_input_handle_key(keycode_Func7); break;
    case VK_F8: gli_input_handle_key(keycode_Func8); break;
    case VK_F9: gli_input_handle_key(keycode_Func9); break;
    case VK_F10: gli_input_handle_key(keycode_Func10); break;
    case VK_F11: gli_input_handle_key(keycode_Func11); break;
    case VK_F12: gli_input_handle_key(keycode_Func12); break;
    }
    return 0;

    /* unicode encoded chars, including escape, backspace etc... */
    case WM_UNICHAR:
        key = wParam;

        if (key == UNICODE_NOCHAR)
            return 1; /* yes, we like WM_UNICHAR */

        if (key == '\r' || key == '\n')
            gli_input_handle_key(keycode_Return);
        else if (key == '\b')
            gli_input_handle_key(keycode_Delete);
        else if (key == '\t')
            gli_input_handle_key(keycode_Tab);
        else if (key == 0x03 || key == 0x18)
            SendMessage(hwndview, WM_COPY, 0, 0);
        else if (key == 0x16)
            SendMessage(hwndview, WM_PASTE, 0, 0);
        else if (key != 27)
            gli_input_handle_key(key);

        return 0;

    case WM_CHAR:
        key = wParam;

        if (key == '\r' || key == '\n')
            gli_input_handle_key(keycode_Return);
        else if (key == '\b')
            gli_input_handle_key(keycode_Delete);
        else if (key == '\t')
            gli_input_handle_key(keycode_Tab);
        else if (key == 0x03 || key == 0x18)
            SendMessage(hwndview, WM_COPY, 0, 0);
        else if (key == 0x16)
            SendMessage(hwndview, WM_PASTE, 0, 0);
        else if (key != 27) {
            /* translate from ANSI code page to Unicode */
            char ansich = (char)key;
            wchar_t widebuf[2];
            int res = MultiByteToWideChar(CP_ACP, 0, &ansich, 1, widebuf, 2);
            if (res) {
                if (Uni_IsSurrogate1(widebuf[0]))
                    key = Uni_SurrogateToUTF32(widebuf[0], widebuf[1]);
                else
                    key = widebuf[0];
                gli_input_handle_key(key);
            }
        }

        return 0;
    }

    /* Pass on unhandled events to Windows */
    return DefWindowProc(hwnd, message, wParam, lParam);
}
コード例 #12
0
ファイル: sysgtk.c プロジェクト: KeanW/zlr--git
static void onkeypress(GtkWidget *widget, GdkEventKey *event, void *data)
{
	int key = event->keyval;

	switch (key)
	{
	case GDK_Return: gli_input_handle_key(keycode_Return); break;
	case GDK_BackSpace: gli_input_handle_key(keycode_Delete); break;
	case GDK_Tab: gli_input_handle_key(keycode_Tab); break;
	case GDK_Prior: gli_input_handle_key(keycode_PageUp); break;
	case GDK_Next: gli_input_handle_key(keycode_PageDown); break;
	case GDK_Home: gli_input_handle_key(keycode_Home); break;
	case GDK_End: gli_input_handle_key(keycode_End); break;
	case GDK_Left: gli_input_handle_key(keycode_Left); break;
	case GDK_Right: gli_input_handle_key(keycode_Right); break;
	case GDK_Up: gli_input_handle_key(keycode_Up); break;
	case GDK_Down: gli_input_handle_key(keycode_Down); break;
	case GDK_Escape: gli_input_handle_key(keycode_Escape); break;
	case GDK_F1: gli_input_handle_key(keycode_Func1); break;
	case GDK_F2: gli_input_handle_key(keycode_Func2); break;
	case GDK_F3: gli_input_handle_key(keycode_Func3); break;
	case GDK_F4: gli_input_handle_key(keycode_Func4); break;
	case GDK_F5: gli_input_handle_key(keycode_Func5); break;
	case GDK_F6: gli_input_handle_key(keycode_Func6); break;
	case GDK_F7: gli_input_handle_key(keycode_Func7); break;
	case GDK_F8: gli_input_handle_key(keycode_Func8); break;
	case GDK_F9: gli_input_handle_key(keycode_Func9); break;
	case GDK_F10: gli_input_handle_key(keycode_Func10); break;
	case GDK_F11: gli_input_handle_key(keycode_Func11); break;
	case GDK_F12: gli_input_handle_key(keycode_Func12); break;
	default:
		if (key >= 32 && key <= 255)
			gli_input_handle_key(key);
	}
}
コード例 #13
0
ファイル: syswin.c プロジェクト: KeanW/zlr--git
LRESULT CALLBACK
viewproc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    int x = (signed short) LOWORD(lParam);
    int y = (signed short) HIWORD(lParam);
    glui32 key;

    switch (message)
    {
    case WM_ERASEBKGND:
	return 1; // don't erase; we'll repaint it all

    case WM_PAINT:
	{
	    PAINTSTRUCT ps;

	    /* make sure we have a fresh bitmap */
	    gli_windows_redraw();

	    /* and blit it to the screen */
	    hdc = BeginPaint(hwnd, &ps);
	    winblit(ps.rcPaint);
	    hdc = NULL;
	    EndPaint(hwnd, &ps);

	    return 0;
	}

    case WM_SIZE:
	{
	    int newwid = LOWORD(lParam);
	    int newhgt = HIWORD(lParam);

	    if (newwid == 0 || newhgt == 0)
		break;

	    if (newwid == gli_image_w && newhgt == gli_image_h)
		break;

	    gli_image_w = newwid;
	    gli_image_h = newhgt;

	    gli_image_s = ((gli_image_w * 3 + 3) / 4) * 4;
	    if (gli_image_rgb)
		free(gli_image_rgb);
	    gli_image_rgb = malloc(gli_image_s * gli_image_h);

	    gli_force_redraw = 1;

	    gli_windows_size_change();

	    break;
	}

    case WM_LBUTTONDOWN:
	gli_input_handle_click(x, y);
	return 0;

    case WM_KEYDOWN:

	switch (wParam)
	{
	case VK_PRIOR: gli_input_handle_key(keycode_PageUp); break;
	case VK_NEXT: gli_input_handle_key(keycode_PageDown); break;
	case VK_HOME: gli_input_handle_key(keycode_Home); break;
	case VK_END: gli_input_handle_key(keycode_End); break;
	case VK_LEFT: gli_input_handle_key(keycode_Left); break;
	case VK_RIGHT: gli_input_handle_key(keycode_Right); break;
	case VK_UP: gli_input_handle_key(keycode_Up); break;
	case VK_DOWN: gli_input_handle_key(keycode_Down); break;
	case VK_ESCAPE: gli_input_handle_key(keycode_Escape); break;
	case VK_F1: gli_input_handle_key(keycode_Func1); break;
	case VK_F2: gli_input_handle_key(keycode_Func2); break;
	case VK_F3: gli_input_handle_key(keycode_Func3); break;
	case VK_F4: gli_input_handle_key(keycode_Func4); break;
	case VK_F5: gli_input_handle_key(keycode_Func5); break;
	case VK_F6: gli_input_handle_key(keycode_Func6); break;
	case VK_F7: gli_input_handle_key(keycode_Func7); break;
	case VK_F8: gli_input_handle_key(keycode_Func8); break;
	case VK_F9: gli_input_handle_key(keycode_Func9); break;
	case VK_F10: gli_input_handle_key(keycode_Func10); break;
	case VK_F11: gli_input_handle_key(keycode_Func11); break;
	case VK_F12: gli_input_handle_key(keycode_Func12); break;
	}
	return 0;

	/* unicode encoded chars, including escape, backspace etc... */
	case WM_UNICHAR:
		key = wParam;

		if (key == UNICODE_NOCHAR)
			return 1; /* yes, we like WM_UNICHAR */

		if (key == '\r' || key == '\n')
			gli_input_handle_key(keycode_Return);
		else if (key == '\b')
			gli_input_handle_key(keycode_Delete);
		else if (key == '\t')
			gli_input_handle_key(keycode_Tab);
		else if (key != 27)
			gli_input_handle_key(key);

		return 0;

    case WM_CHAR:
		key = wParam;

		if (key == '\r' || key == '\n')
			gli_input_handle_key(keycode_Return);
		else if (key == '\b')
			gli_input_handle_key(keycode_Delete);
		else if (key == '\t')
			gli_input_handle_key(keycode_Tab);
		else if (key != 27) {
			/* translate from ANSI code page to Unicode */
			char ansich = (char)key;
			wchar_t widebuf[2];
			int res = MultiByteToWideChar(CP_ACP, 0, &ansich, 1, widebuf, 2);
			if (res) {
				if (Uni_IsSurrogate1(widebuf[0]))
					key = Uni_SurrogateToUTF32(widebuf[0], widebuf[1]);
				else
					key = widebuf[0];
				gli_input_handle_key(key);
			}
		}

		return 0;
    }

    /* Pass on unhandled events to Windows */
    return DefWindowProc(hwnd, message, wParam, lParam);
}