forked from sabrogden/Ditto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainTableFunctions.cpp
115 lines (94 loc) · 2.44 KB
/
MainTableFunctions.cpp
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
// MainTableFunctions.cpp: implementation of the CMainTableFunctions class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "cp_main.h"
#include "MainTableFunctions.h"
#include "shared/Tokenizer.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CMainTableFunctions::CMainTableFunctions()
{
}
CMainTableFunctions::~CMainTableFunctions()
{
}
void CMainTableFunctions::LoadAcceleratorKeys(CAccels& accels, CppSQLite3DB &db)
{
try
{
{
CppSQLite3Query q = db.execQuery(_T("SELECT lID, lShortCut FROM Main WHERE lShortCut > 0"));
CAccel a;
while(q.eof() == false)
{
a.Cmd = q.getIntField(_T("lID"));
a.Key = q.getIntField(_T("lShortCut"));
a.RefId = CHotKey::PASTE_OPEN_CLIP;
accels.AddAccel(a);
q.nextRow();
}
}
{
CppSQLite3Query q2 = db.execQuery(_T("SELECT lID, MoveToGroupShortCut FROM Main WHERE MoveToGroupShortCut > 0"));
CAccel a2;
while(q2.eof() == false)
{
a2.Cmd = q2.getIntField(_T("lID"));
a2.Key = q2.getIntField(_T("MoveToGroupShortCut"));
a2.RefId = CHotKey::MOVE_TO_GROUP;
accels.AddAccel(a2);
q2.nextRow();
}
}
}
CATCH_SQLITE_EXCEPTION
}
CString CMainTableFunctions::GetDisplayText(int nMaxLines, const CString &OrigText)
{
CString text = OrigText;
// assign tabs to 2 spaces (rather than the default 8)
text.Replace(_T("\t"), _T(" "));
if(g_Opt.m_bDescShowLeadingWhiteSpace)
return text;
// else, remove the leading indent from every line.
// get the lines
CString token;
CStringArray tokens;
CTokenizer tokenizer(text, "\r\n");
for(int nLines=0; nLines < 100 && tokenizer.Next(token); nLines++)
{
tokens.Add(token);
}
// remove each line's indent
TCHAR chFirst;
CString line;
INT_PTR count = tokens.GetSize();
text = _T("");
for(int i=0; i < count; i++)
{
line = tokens.ElementAt(i);
chFirst = line.GetAt(0);
if(chFirst == ' ' || chFirst == '\t')
{
text += _T("» "); // show indication that the line is modified
line.TrimLeft();
text += line;
}
else
{
text += line;
}
if (i != count - 1)
{
text += _T("\n");
}
}
return text;
}