File: ascii.c

package info (click to toggle)
biew 5.6.2-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 4,000 kB
  • ctags: 7,157
  • sloc: ansic: 50,860; asm: 809; makefile: 396; pascal: 371
file content (87 lines) | stat: -rw-r--r-- 2,424 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/**
 * @namespace   biew_addons
 * @file        addons/sys/ascii.c
 * @brief       This file contains simple implementation ASCII table viewer.
 * @version     -
 * @remark      this source file is part of Binary vIEW project (BIEW).
 *              The Binary vIEW (BIEW) is copyright (C) 1995 Nick Kurshev.
 *              All rights reserved. This software is redistributable under the
 *              licence given in the file "Licence.en" ("Licence.ru" in russian
 *              translation) distributed in the BIEW archive.
 * @note        Requires POSIX compatible development system
 *
 * @author      Nick Kurshev
 * @since       1995
 * @note        Development, fixes and improvements
 * @author      Alexander Krisak and Andrew Golovnia
 * @date        23.07.2003
 * @note        Russian locales support: KOI-8, CP866, CP1251, ISO8859-5.
 *              Tested at ASPLinux 7.3 and ASPLinux 9
**/
#include <string.h>

#include "bconsole.h"
#include "reg_form.h"
#include "biewutil.h"
#include "colorset.h"
#include "biewlib/biewlib.h"
#include "biewlib/kbd_code.h"

static TWindow * __NEAR__ __FASTCALL__ CreatePanelNF(tAbsCoord x1,tAbsCoord y1,tAbsCoord x2,tAbsCoord y2)
{
 TWindow *win;
 unsigned flags = 0;
 win = WindowOpen(x1,y1,x2,y2,flags);
 twSetColorAttr(dialog_cset.main);
 twClearWin();
 twShowWin(win);
 return win;
}

static void ShowASCII( void )
{
  TWindow * hwnd = CrtDlgWndnls(" ASCII table ",34,18);
  TWindow * hpnl = CreatePanelNF(hwnd->X1+4,hwnd->Y1+4,hwnd->X2-1,hwnd->Y2-1);
  unsigned evt;
  int i,j;
  unsigned char str[35];
  twUseWin(hwnd);
  twFreezeWin(hwnd);
  strcpy((char *)str,"0 1 2 3 4 5 6 7 8 9 A B C D E F");
  twDirectWrite(1,1,str,34);
  str[0] = TWC_SH;
  str[1] = 0;
  for(i = 0;i < 34;i++)  twDirectWrite(i+1,2,str,1);
  str[1] = TWC_SV;
  str[2] = 0;
  for(i = 0;i < 16;i++) { str[0] = i < 0x0A ? i + '0' : i - 0x0A + 'A'; twDirectWrite(1,i+3,str,2); }
  str[0] = TWC_SV_SH;
  str[1] = 0;
  twDirectWrite(2,2,str,1);
  twUseWin(hpnl);
  twFreezeWin(hpnl);
  for(i = 0;i < 16;i++)
  {
    for(j = 0;j < 16;j++) { str[j*2] = i*16 + j; str[j*2 + 1] = ' '; }
    twDirectWrite(1,i+1,str,31);
  }
  twRefreshWin(hpnl);
  twRefreshWin(hwnd);
  do
  {
    evt = GetEvent(drawEmptyPrompt,NULL,hwnd);
  }
  while(!(evt == KE_ESCAPE || evt == KE_F(10)));
  CloseWnd(hpnl);
  CloseWnd(hwnd);
}

REGISTRY_SYSINFO AsciiTable =
{
  "~ASCII table",
  ShowASCII,
  NULL,
  NULL
};