-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathunit8.pas
More file actions
226 lines (193 loc) · 5.63 KB
/
unit8.pas
File metadata and controls
226 lines (193 loc) · 5.63 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
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
// ***********************************************************************
// ***********************************************************************
// mxMarkEdit 1.x
// Author and copyright: Massimo Nardello, Modena (Italy) 2024 - 2025.
// Free software released under GPL licence version 3 or later.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. You can read the version 3
// of the Licence in http://www.gnu.org/licenses/gpl-3.0.txt
// or in the file Licence.txt included in the files of the
// source code of this software.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// ***********************************************************************
// ***********************************************************************
unit Unit8;
{$mode ObjFPC}{$H+}
{$modeswitch objectivec1}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, Grids, ExtCtrls,
StdCtrls, LazUTF8, translate, CocoaAll, CocoaTextEdits, CocoaUtils;
type
{ TfmEditor }
TfmEditor = class(TForm)
bnLeft: TButton;
bnUp: TButton;
bnDown: TButton;
bnRight: TButton;
dbEditor: TMemo;
pnTasks: TPanel;
bnOK: TButton;
procedure bnDownClick(Sender: TObject);
procedure bnLeftClick(Sender: TObject);
procedure bnOKClick(Sender: TObject);
procedure bnRightClick(Sender: TObject);
procedure bnUpClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormHide(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure FormShow(Sender: TObject);
private
procedure LoadCell;
procedure SaveCell;
public
end;
var
fmEditor: TfmEditor;
resourcestring
lbedit001 = 'Cell';
implementation
uses Unit1;
{$R *.lfm}
{ TfmEditor }
procedure TfmEditor.FormCreate(Sender: TObject);
begin
if IsAppDark = True then
begin
dbEditor.Font.Color := clWhite;
end
else
begin
dbEditor.Font.Color := clBlack;
dbEditor.Color := clWhite;
end;
end;
procedure TfmEditor.FormActivate(Sender: TObject);
begin
TCocoaTextView(NSScrollView(dbEditor.Handle).documentView).
setContinuousSpellCheckingEnabled(True);
TCocoaTextView(NSScrollView(dbEditor.Handle).documentView).
setGrammarCheckingEnabled(False);
TCocoaTextView(NSScrollView(dbEditor.Handle).documentView).
setFocusRingType(1);
TCocoaTextView(NSScrollView(dbEditor.Handle).documentView).
setAutomaticQuoteSubstitutionEnabled(True);
TCocoaTextView(NSScrollView(dbEditor.Handle).documentView).
setSmartInsertDeleteEnabled(True);
TCocoaTextView(NSScrollView(dbEditor.Handle).documentView).
setAutomaticLinkDetectionEnabled(True);
TCocoaTextView(NSScrollView(dbEditor.Handle).documentView).
setImportsGraphics(False);
TCocoaTextView(NSScrollView(dbEditor.Handle).documentView).
setRichText(False);
TCocoaTextView(NSScrollView(dbEditor.Handle).documentView).
textContainer.setLineFragmentPadding(20);
TCocoaTextView(NSScrollView(dbEditor.Handle).documentView).
checkTextInDocument(nil);
TCocoaTextView(NSScrollView(dbEditor.Handle).documentView).
undoManager.removeAllActions;
dbEditor.Font.Name := fmMain.dbText.Font.Name;
end;
procedure TfmEditor.FormShow(Sender: TObject);
begin
LoadCell;
end;
procedure TfmEditor.FormHide(Sender: TObject);
begin
SaveCell;
end;
procedure TfmEditor.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if ((key = 37) and (Shift = [ssMeta, ssAlt])) then
begin
bnLeftClick(nil);
key := 0;
end
else
if ((key = 38) and (Shift = [ssMeta, ssAlt])) then
begin
bnUpClick(nil);
key := 0;
end
else
if ((key = 39) and (Shift = [ssMeta, ssAlt])) then
begin
bnRightClick(nil);
key := 0;
end
else
if ((key = 40) and (Shift = [ssMeta, ssAlt])) then
begin
bnDownClick(nil);
key := 0;
end
else
if key = 27 then
begin
Close;
key := 0;
end;
end;
procedure TfmEditor.bnOKClick(Sender: TObject);
begin
Close;
end;
procedure TfmEditor.bnLeftClick(Sender: TObject);
begin
if fmMain.sgTable.Col > 1 then
begin
SaveCell;
fmMain.sgTable.Col := fmMain.sgTable.Col - 1;
LoadCell;
end;
end;
procedure TfmEditor.bnUpClick(Sender: TObject);
begin
if fmMain.sgTable.Row > 1 then
begin
SaveCell;
fmMain.sgTable.Row := fmMain.sgTable.Row - 1;
LoadCell;
end;
end;
procedure TfmEditor.bnDownClick(Sender: TObject);
begin
if fmMain.sgTable.Row < fmMain.sgTable.RowCount - 1 then
begin
SaveCell;
fmMain.sgTable.Row := fmMain.sgTable.Row + 1;
LoadCell;
end;
end;
procedure TfmEditor.bnRightClick(Sender: TObject);
begin
if fmMain.sgTable.Col < fmMain.sgTable.ColCount - 1 then
begin
SaveCell;
fmMain.sgTable.Col := fmMain.sgTable.Col + 1;
LoadCell;
end;
end;
procedure TfmEditor.LoadCell;
begin
dbEditor.Text := fmMain.sgTable.Cells[fmMain.sgTable.Col, fmMain.sgTable.Row];
dbEditor.SelStart := 0;
fmEditor.Caption := lbedit001 + ' ' + IntToStr(fmMain.sgTable.Row) + ' / ' +
fmMain.sgTable.Cells[fmMain.sgTable.Col, 0];
end;
procedure TfmEditor.SaveCell;
var
stText: String;
begin
stText := dbEditor.Text;
stText := UTF8StringReplace(stText, #9, ' ', [rfReplaceAll]);
fmMain.sgTable.Cells[fmMain.sgTable.Col, fmMain.sgTable.Row] := stText;
end;
end.