📄 bigaterm.cpp
字号:
#include "../win_and_sock.h"
#include "bigaterm.h"
#include <stdio.h>
//#include "../roxy.h" // TODO: remove
#define BT_NUM_LINES 200
#define BT_TEXT_HMARG 2
#define BT_TEXT_VMARG 2
#define BT_SCROLL_SIZE 16
#define BT_SCROLLER_SIZE 20
typedef struct TBTLine
{
char * str;
int strlen;
COLORREF color;
}TBTLine;
typedef struct TBigaTermData
{
TBTLine lines[BT_NUM_LINES];
int arr_start;
int arr_len;
int view_offset; // less then arr_len
int scroller_offset;
int scroller_drag;
int line_height;
HFONT font1;
HBRUSH green_brush, bg_brush;
int voff_last;
}TBigaTermData;
// forward declaration
LRESULT CALLBACK BTermWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
ATOM BigaTermRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)BTermWndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = sizeof(LONG);
wcex.hInstance = hInstance;
wcex.lpszClassName = "BigaTerm";
wcex.lpszMenuName = NULL;
wcex.hIcon = NULL;
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = CreateSolidBrush(BT_BKCOLOR);
wcex.hIconSm = NULL;
return RegisterClassEx(&wcex);
}
void allocWndExtra(HWND hWnd)
{
TBigaTermData * p;
SIZE lnSz;
HDC hdc;
RECT cli_rect;
GetClientRect(hWnd, &cli_rect);
// allocating structure in memory;
p = (TBigaTermData *)malloc(sizeof(TBigaTermData));
// filling data with zeros
memset(p, 0, sizeof(TBigaTermData));
hdc = GetDC(hWnd);
p->font1 = CreateFont(
10, // height of font
0, // average character width
0, // angle of escapement
0, // base-line orientation angle
FW_REGULAR, // font weight
FALSE, // italic attribute option
FALSE, // underline attribute option
FALSE, // strikeout attribute option
RUSSIAN_CHARSET, // character set identifier
OUT_CHARACTER_PRECIS, // output precision
CLIP_DEFAULT_PRECIS, // clipping precision
DEFAULT_QUALITY, // output quality
FF_DONTCARE, // pitch and family
"Fixedsys" // typeface name
);
SelectObject(hdc, p->font1); // select font
p->green_brush = CreateSolidBrush(BT_FCOLOR);
p->bg_brush = CreateSolidBrush(BT_BKCOLOR);
SetBkColor(hdc, 0);
p->view_offset = 0;
p->scroller_offset = 0;
p->scroller_drag = INT_MIN; // not dragging
GetTextExtentPoint32(hdc, "ROxy", 4 /*潆桧
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -