Rev 94 | Rev 97 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 94 | Rev 96 | ||
---|---|---|---|
Line 18... | Line 18... | ||
18 | // TODO: Wieso dauert webbrowser1 erste kompilierung so lange??? |
18 | // TODO: Wieso dauert webbrowser1 erste kompilierung so lange??? |
19 | // TODO: wieso kommt syntax fehler zweimal? einmal stderr einmal stdout? |
19 | // TODO: wieso kommt syntax fehler zweimal? einmal stderr einmal stdout? |
20 | // TODO: Browser titlebar (link preview) |
20 | // TODO: Browser titlebar (link preview) |
21 | // TODO: "jump to next/prev todo" buttons/shortcuts |
21 | // TODO: "jump to next/prev todo" buttons/shortcuts |
22 | // TODO: "increase/decrease indent" buttons/shortcuts |
22 | // TODO: "increase/decrease indent" buttons/shortcuts |
23 | - | ||
24 | // In regards Unicode: |
- | |
25 | // - Solve compiler warnings |
- | |
26 | // - If you place Unicode symbols in a ANSI file, they will be replaced during saving |
23 | // TODO: Solve all compiler warnings, especially in regards Encoding |
27 | // by "?" without asking the user if the code should be converted to Unicode! |
- | |
28 | // - Is it possible that UTF8 BOM automatically gets removed by FastPHP, generating pure ANSI? |
- | |
29 | 24 | ||
30 | // Note in re Unicode: |
25 | // Note in re Unicode: |
31 | // - In Embarcadero® Delphi 10.4 Version 27.0.40680.4203: |
26 | // - In Embarcadero® Delphi 10.4 Version 27.0.40680.4203: |
32 | // SynEdit correctly detects UTF-8 files without BOM as well as ANSI files with Umlauts. |
27 | // SynEdit correctly detects UTF-8 files without BOM as well as ANSI files with Umlauts. |
33 | // (Previous versions could not detect UTF-8 files without BOM?!) |
28 | // (Previous versions could not detect UTF-8 files without BOM?!) |
34 | // - If BOM is existing, it will be removed. (which is good, because this is defined by PSR-1) |
29 | // - If BOM is existing, it will be removed. (which is good, because this is defined by PSR-1) |
35 | 30 | ||
36 | // Small things: |
31 | // Small things: |
37 | // - The scroll bars of SynEdit are not affected by the dark theme |
32 | // - The scroll bars of SynEdit are not affected by the dark theme |
- | 33 | // - dark theme full screen: doubleclick to desktop pixel "0,0" cannot be used to close the app |
|
38 | 34 | ||
39 | // Future ideas |
35 | // Future ideas |
40 | // - code insight |
36 | // - code insight |
41 | // - verschiedene php versionen? |
37 | // - verschiedene php versionen? |
42 | // - webbrowser1 nur laden, wenn man den tab anw�hlt? |
38 | // - webbrowser1 nur laden, wenn man den tab anw�hlt? |
Line 218... | Line 214... | ||
218 | procedure RefreshModifySign; |
214 | procedure RefreshModifySign; |
219 | procedure Theme_Light; |
215 | procedure Theme_Light; |
220 | procedure Theme_Dark; |
216 | procedure Theme_Dark; |
221 | function IsThemeDark: boolean; |
217 | function IsThemeDark: boolean; |
222 | function MarkUpLineReference(cont: string): string; |
218 | function MarkUpLineReference(cont: string): string; |
- | 219 | function ContainsUnicodeCharsInAnsiFile: boolean; |
|
223 | procedure SaveToFile(filename: string); |
220 | procedure SaveToFile(filename: string); |
224 | end; |
221 | end; |
225 | 222 | ||
226 | var |
223 | var |
227 | Form1: TForm1; |
224 | Form1: TForm1; |
Line 1183... | Line 1180... | ||
1183 | DragAcceptFiles(Handle, True); |
1180 | DragAcceptFiles(Handle, True); |
1184 | 1181 | ||
1185 | StartupTimer.Enabled := true; |
1182 | StartupTimer.Enabled := true; |
1186 | end; |
1183 | end; |
1187 | 1184 | ||
- | 1185 | function TForm1.ContainsUnicodeCharsInAnsiFile: boolean; |
|
- | 1186 | var |
|
- | 1187 | lines: TStringList; |
|
- | 1188 | ms: TMemoryStream; |
|
- | 1189 | begin |
|
- | 1190 | if SynEdit1.Lines.Encoding = TEncoding.UTF8 then |
|
- | 1191 | begin |
|
- | 1192 | result := false; |
|
- | 1193 | exit; |
|
- | 1194 | end; |
|
- | 1195 | ||
- | 1196 | lines := TStringList.Create; |
|
- | 1197 | ms := TMemoryStream.Create; |
|
- | 1198 | try |
|
- | 1199 | SynEdit1.Lines.SaveToStream(ms); |
|
- | 1200 | ms.Position := 0; |
|
- | 1201 | lines.LoadFromStream(ms); |
|
- | 1202 | result := Trim(lines.Text) <> Trim(synedit1.Lines.Text); |
|
- | 1203 | finally |
|
- | 1204 | FreeAndNil(ms); |
|
- | 1205 | FreeAndNil(lines); |
|
- | 1206 | end; |
|
- | 1207 | end; |
|
- | 1208 | ||
1188 | procedure TForm1.SaveToFile(filename: string); |
1209 | procedure TForm1.SaveToFile(filename: string); |
1189 | var |
1210 | var |
1190 | ss: TStringStream; |
1211 | ss: TStringStream; |
1191 | ms: TMemoryStream; |
1212 | ms: TMemoryStream; |
1192 | fs: TFileStream; |
1213 | fs: TFileStream; |
1193 | eolStyle: string; |
1214 | eolStyle: string; |
1194 | str: string; |
1215 | str: string; |
- | 1216 | UpgradeEncodingToUnicode: boolean; |
|
- | 1217 | DoReloadEncoding: boolean; |
|
- | 1218 | resourcestring |
|
- | 1219 | LNG_UpgradeToUtf8 = 'Unicode characters have been inserted to this ANSI encoded file. Convert file to UTF-8? (If you choose "No", the Unicode characters will be replaced with "?")'; |
|
1195 | begin |
1220 | begin |
1196 | FileModTimer.Enabled := false; |
1221 | FileModTimer.Enabled := false; |
1197 | 1222 | ||
- | 1223 | if ContainsUnicodeCharsInAnsiFile then |
|
- | 1224 | begin |
|
- | 1225 | DoReloadEncoding := true; |
|
- | 1226 | case MessageBox(Handle, PChar(LNG_UpgradeToUtf8), PChar(Caption), MB_YESNOCANCEL) of |
|
- | 1227 | ID_YES: |
|
- | 1228 | begin |
|
- | 1229 | UpgradeEncodingToUnicode := true; |
|
- | 1230 | end; |
|
- | 1231 | ID_NO: |
|
- | 1232 | begin |
|
- | 1233 | UpgradeEncodingToUnicode := false; |
|
- | 1234 | end; |
|
- | 1235 | ID_CANCEL: |
|
- | 1236 | begin |
|
- | 1237 | Abort; |
|
- | 1238 | end; |
|
- | 1239 | end; |
|
- | 1240 | end |
|
- | 1241 | else |
|
- | 1242 | begin |
|
- | 1243 | DoReloadEncoding := false; |
|
- | 1244 | UpgradeEncodingToUnicode := false; |
|
- | 1245 | end; |
|
- | 1246 | ||
1198 | ms := TMemoryStream.Create; |
1247 | ms := TMemoryStream.Create; |
1199 | ss := TStringStream.Create(''); |
1248 | ss := TStringStream.Create(''); |
1200 | fs := TFileStream.Create(filename, fmCreate); |
1249 | fs := TFileStream.Create(filename, fmCreate); |
1201 | try |
1250 | try |
1202 | // Save everything in a memory stream and then to a string |
1251 | // Save everything in a memory stream and then to a string |
1203 | // in comparison to "str := SynEdit1.Lines.Text;", |
1252 | // in comparison to "str := SynEdit1.Lines.Text;", |
1204 | // This approach should preserve LF / CRLF line endings |
1253 | // This approach should preserve LF / CRLF line endings |
- | 1254 | if UpgradeEncodingToUnicode then |
|
- | 1255 | SynEdit1.Lines.SaveToStream(ms, TEncoding.UTF8) // upgrade an ANSI file to UTF-8 (e.g. if you include Japanese characters) |
|
- | 1256 | else |
|
1205 | SynEdit1.Lines.SaveToStream(ms); |
1257 | SynEdit1.Lines.SaveToStream(ms); |
- | 1258 | if DoReloadEncoding then |
|
- | 1259 | begin |
|
- | 1260 | ms.Position := 0; |
|
- | 1261 | SynEdit1.Lines.LoadFromStream(ms); |
|
- | 1262 | end; |
|
1206 | ms.Position := 0; |
1263 | ms.Position := 0; |
1207 | ss.CopyFrom(ms, ms.Size); |
1264 | ss.CopyFrom(ms, ms.Size); |
1208 | ss.Position := 0; |
1265 | ss.Position := 0; |
1209 | str := ss.ReadString(ss.Size); |
1266 | str := ss.ReadString(ss.Size); |
1210 | ss.Size := 0; // clear string-stream, because we need it later again |
1267 | ss.Size := 0; // clear string-stream, because we need it later again |