-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEditPlus.h
More file actions
82 lines (66 loc) · 3.11 KB
/
EditPlus.h
File metadata and controls
82 lines (66 loc) · 3.11 KB
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
#pragma once
#include <windows.h>
#include <windowsx.h>
#include <CommCtrl.h>
#include <crtdbg.h>
//#define MAKEPOINT(l) (*((LPPOINT)&(l)))
inline POINT MAKEPOINT(DWORD l)
{
POINT pt;
pt.x = LOWORD(l);
pt.y = HIWORD(l);
return pt;
}
inline HWND Edit_Create(HWND hParent, DWORD dwStyle, RECT rc, int id)
{
HWND hWnd = CreateWindow(
WC_EDIT,
TEXT(""),
dwStyle,
rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top,
hParent,
(HMENU) (INT_PTR) id,
NULL,
NULL);
_ASSERT(hWnd != NULL);
return hWnd;
}
#define EM_CANREDO 0x00E0
#define EM_REDO 0x00E1
//#define Edit_GetSelEx(hwndCtl, ichStart, ichEnd) ((void)SNDMSG((hwndCtl), EM_GETSEL, (WPARAM)(ichStart), (LPARAM)(ichEnd)))
//#define Edit_ReplaceSelEx(hwndCtl, lpszReplace, allowundo) ((void)SNDMSG((hwndCtl), EM_REPLACESEL, allowundo, (LPARAM)(LPCTSTR)(lpszReplace)))
//#define Edit_Scroll(hwndCtl, dv, dh) ((DWORD)SNDMSG((hwndCtl), EM_LINESCROLL, (WPARAM)(dh), (LPARAM)(dv)))
//#define Edit_CanRedo(hwndCtl) ((BOOL)(DWORD)SNDMSG((hwndCtl), EM_CANREDO, 0L, 0L))
//#define Edit_Redo(hwndCtl) ((BOOL)(DWORD)SNDMSG((hwndCtl), EM_REDO, 0L, 0L))
inline void Edit_GetSelEx(HWND hwndCtl, DWORD* ichStart, DWORD* ichEnd) { ((void) SNDMSG((hwndCtl), EM_GETSEL, (WPARAM) (ichStart), (LPARAM) (ichEnd))); }
inline void Edit_ReplaceSelEx(HWND hwndCtl, LPCTSTR lpszReplace, BOOL allowundo) { ((void) SNDMSG((hwndCtl), EM_REPLACESEL, allowundo, (LPARAM) (LPCTSTR) (lpszReplace))); }
inline DWORD Edit_ScrollEx(HWND hwndCtl, UINT action) { return ((DWORD) SNDMSG((hwndCtl), EM_SCROLL, (WPARAM) (action), 0)); }
inline POINT Edit_GetPosFromChar(HWND hwndCtl, UINT nChar) { return MAKEPOINT((DWORD) SNDMSG((hwndCtl), EM_POSFROMCHAR, (WPARAM) (nChar), 0)); }
inline int Edit_GetLimitText(HWND hwndCtl) { return ((int) SNDMSG((hwndCtl), EM_GETLIMITTEXT, 0, 0)); }
inline bool Edit_CanRedo(HWND hwndCtl) { return ((BOOL) (DWORD) SNDMSG((hwndCtl), EM_CANREDO, 0L, 0L)); }
inline bool Edit_Redo(HWND hwndCtl) { return ((BOOL) (DWORD) SNDMSG((hwndCtl), EM_REDO, 0L, 0L)); }
void Edit_ReplaceLineEndings(HWND hWnd);
inline POINT EditGetPos(HWND hWnd, const DWORD dwCaret)
{
const int nLine = Edit_GetFileLineFromChar(hWnd, dwCaret);
const int nLineIndex = Edit_GetFileLineIndex(hWnd, nLine);
return { (LONG) (dwCaret - nLineIndex + 1), (LONG) (nLine + 1) };
}
inline DWORD EditGetFirstVisibleFileLine(HWND hWnd)
{
const int first = Edit_GetFirstVisibleLine(hWnd);
const int index = Edit_LineIndex(hWnd, first);
return Edit_GetFileLineFromChar(hWnd, index);
}
void InitEditEx(HWND hWnd);
// Edit Plus Notifications
#define EN_SEL_CHANGED 0x0A00
// Edit Plus Styles
#define ES_EX_VIEWWHITESPACE 0x0100
#define ES_EX_LINENUMBERS 0x0200
#define ES_EX_USETABS 0x0400
// TODO
// bookmarks
// show unprintable characters
// Edit_SetCaretIndex has an error newCaretPosition/newCaretIndex
inline BOOL Edit_SetCaretIndexEx(HWND hwndCtl, int newCaretPosition) { return (BOOL) SNDMSG((hwndCtl), EM_SETCARETINDEX, (WPARAM) (newCaretPosition), 0); }