From 356554c22998264769a5c516697cbfbd43847ce4 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sat, 4 Apr 2015 21:29:33 -0400 Subject: textscreen: Add help URL functionality for windows. This adds the ability to associate a URL with a window that gives some extra information about it and the configuration options found in it. --- textscreen/txt_desktop.c | 85 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 80 insertions(+), 5 deletions(-) (limited to 'textscreen/txt_desktop.c') diff --git a/textscreen/txt_desktop.c b/textscreen/txt_desktop.c index 4c9cf5c1..e56a5ee4 100644 --- a/textscreen/txt_desktop.c +++ b/textscreen/txt_desktop.c @@ -25,6 +25,7 @@ #include "txt_separator.h" #include "txt_window.h" +#define HELP_KEY KEY_F1 #define MAXWINDOWS 128 static char *desktop_title; @@ -188,6 +189,37 @@ static void DrawDesktopBackground(const char *title) TXT_Puts(title); } +static void DrawHelpIndicator(void) +{ + char keybuf[10]; + int fgcolor; + int x, y; + + TXT_GetKeyDescription(HELP_KEY, keybuf, sizeof(keybuf)); + + TXT_GetMousePosition(&x, &y); + + if (y == 0 && x >= TXT_SCREEN_W - 9) + { + fgcolor = TXT_COLOR_GREY; + TXT_BGColor(TXT_COLOR_BLACK, 0); + } + else + { + fgcolor = TXT_COLOR_BLACK; + TXT_BGColor(TXT_COLOR_GREY, 0); + } + + TXT_GotoXY(TXT_SCREEN_W - 9, 0); + + TXT_FGColor(TXT_COLOR_BRIGHT_WHITE); + TXT_DrawString(" "); + TXT_DrawString(keybuf); + + TXT_FGColor(fgcolor); + TXT_DrawString("=Help "); +} + void TXT_SetDesktopTitle(char *title) { free(desktop_title); @@ -197,8 +229,9 @@ void TXT_SetDesktopTitle(char *title) void TXT_DrawDesktop(void) { - int i; + txt_window_t *active_window; const char *title; + int i; TXT_InitClipArea(); @@ -209,6 +242,12 @@ void TXT_DrawDesktop(void) DrawDesktopBackground(title); + active_window = TXT_GetActiveWindow(); + if (active_window != NULL && active_window->help_url != NULL) + { + DrawHelpIndicator(); + } + for (i=0; i= TXT_SCREEN_W - 9) + { + DesktopInputEvent(HELP_KEY); + } + break; + + case HELP_KEY: + active_window = TXT_GetActiveWindow(); + if (active_window != NULL) + { + TXT_OpenWindowHelpURL(active_window); + } + break; + + default: + break; + } + + +} + void TXT_DispatchEvents(void) { + txt_window_t *active_window; int c; while ((c = TXT_GetChar()) > 0) { - if (num_windows > 0) - { - // Send the keypress to the top window + active_window = TXT_GetActiveWindow(); - TXT_WindowKeyPress(all_windows[num_windows - 1], c); + if (active_window != NULL && !TXT_WindowKeyPress(active_window, c)) + { + DesktopInputEvent(c); } } } -- cgit v1.2.3