| 1 | /* |
|---|
| 2 | * neercs console-based window manager |
|---|
| 3 | * Copyright (c) 2006 Sam Hocevar <sam@zoy.org> |
|---|
| 4 | * 2008 Jean-Yves Lamoureux <jylam@lnxscene.org> |
|---|
| 5 | * All Rights Reserved |
|---|
| 6 | * |
|---|
| 7 | * $Id: help.c 3996 2009-11-22 12:41:45Z jylam $ |
|---|
| 8 | * |
|---|
| 9 | * This program is free software. It comes without any warranty, to |
|---|
| 10 | * the extent permitted by applicable law. You can redistribute it |
|---|
| 11 | * and/or modify it under the terms of the Do What The Fuck You Want |
|---|
| 12 | * To Public License, Version 2, as published by Sam Hocevar. See |
|---|
| 13 | * http://sam.zoy.org/wtfpl/COPYING for more details. |
|---|
| 14 | */ |
|---|
| 15 | |
|---|
| 16 | #include "config.h" |
|---|
| 17 | |
|---|
| 18 | #include <stdio.h> |
|---|
| 19 | #include <stdlib.h> |
|---|
| 20 | #include <string.h> |
|---|
| 21 | #include <caca.h> |
|---|
| 22 | #include <caca.h> |
|---|
| 23 | #include <time.h> |
|---|
| 24 | #include <sys/wait.h> |
|---|
| 25 | #include <sys/types.h> |
|---|
| 26 | |
|---|
| 27 | #include "neercs.h" |
|---|
| 28 | |
|---|
| 29 | int help_handle_key(struct screen_list *screen_list, unsigned int c) |
|---|
| 30 | { |
|---|
| 31 | if (c == CACA_KEY_ESCAPE || c == 'h') |
|---|
| 32 | { |
|---|
| 33 | screen_list->modals.help = 0; |
|---|
| 34 | screen_list->changed = 1; |
|---|
| 35 | return 1; |
|---|
| 36 | } |
|---|
| 37 | else |
|---|
| 38 | { |
|---|
| 39 | return 0; |
|---|
| 40 | } |
|---|
| 41 | } |
|---|
| 42 | |
|---|
| 43 | void draw_help(struct screen_list *screen_list) |
|---|
| 44 | { |
|---|
| 45 | int w = 65, h = 20; |
|---|
| 46 | int x = (caca_get_canvas_width(screen_list->cv) - w) / 2; |
|---|
| 47 | int y = (caca_get_canvas_height(screen_list->cv) - h) / 2; |
|---|
| 48 | |
|---|
| 49 | |
|---|
| 50 | caca_set_color_ansi(screen_list->cv, CACA_BLUE, CACA_BLUE); |
|---|
| 51 | caca_fill_box(screen_list->cv, x, y, w, h, '#'); |
|---|
| 52 | caca_set_color_ansi(screen_list->cv, CACA_DEFAULT, CACA_BLUE); |
|---|
| 53 | caca_draw_cp437_box(screen_list->cv, x, y, w, h); |
|---|
| 54 | |
|---|
| 55 | x += 2; |
|---|
| 56 | y++; |
|---|
| 57 | caca_printf(screen_list->cv, |
|---|
| 58 | (caca_get_canvas_width(screen_list->cv) - |
|---|
| 59 | strlen(PACKAGE_STRING)) / 2, y - 1, PACKAGE_STRING); |
|---|
| 60 | caca_printf(screen_list->cv, x, y++, "Copyright (c) 2006-2009"); |
|---|
| 61 | caca_printf(screen_list->cv, x, y++, " Sam Hocevar <sam@zoy.org>"); |
|---|
| 62 | caca_printf(screen_list->cv, x, y++, " Jean-Yves Lamoureux <jylam@lnxscene.org>"); |
|---|
| 63 | caca_printf(screen_list->cv, x, y++, " Pascal Terjan <pterjan@linuxfr.org>"); |
|---|
| 64 | caca_printf(screen_list->cv, x, y++, ""); |
|---|
| 65 | caca_printf(screen_list->cv, x, y++, ""); |
|---|
| 66 | caca_printf(screen_list->cv, x, y++, "All shortcuts are in format 'ctrl-a-X' where X is :"); |
|---|
| 67 | caca_printf(screen_list->cv, x, y++, "n:\t Next window"); |
|---|
| 68 | caca_printf(screen_list->cv, x, y++, "p:\t Previous window"); |
|---|
| 69 | caca_printf(screen_list->cv, x, y++, "w:\t Switch window manager"); |
|---|
| 70 | caca_printf(screen_list->cv, x, y++, "c:\t Create new window"); |
|---|
| 71 | caca_printf(screen_list->cv, x, y++, "m:\t Thumbnails"); |
|---|
| 72 | caca_printf(screen_list->cv, x, y++, "d:\t Detach"); |
|---|
| 73 | caca_printf(screen_list->cv, x, y++, "k:\t Close window and kill associated process"); |
|---|
| 74 | caca_printf(screen_list->cv, x, y++, "h:\t This help"); |
|---|
| 75 | caca_printf(screen_list->cv, x, y++, ""); |
|---|
| 76 | caca_printf(screen_list->cv, x, y++, ""); |
|---|
| 77 | caca_printf(screen_list->cv, x, y, "See http://caca.zoy.org/wiki/neercs for more informations"); |
|---|
| 78 | } |
|---|