📄 editmodule.pas
字号:
Result := P - PChar(t) + 1;
Exit;
End;
// P^ := #0;
Inc(P);
P := AnsiStrScan(P, Seperator);
End;
End;
{StrFunc ---End}
Function TFilterList.GetFilterPos(Const AIndex: Integer; Var StartPos, Endpos: Integer): Boolean;
Var
t, m: Integer;
Begin
Result := False;
t := Count;
If (AIndex + 1) > t Then Exit;
m := AIndex * 2;
If AIndex = 0 Then
StartPos := 1
Else
StartPos := SeperatorPosition(m, Filters, '|') + 1;
If (AIndex + 1) = t Then //the last index
Endpos := Length(Filters)
Else Begin
Endpos := SeperatorPosition(m + 2, Filters, '|') - 1;
End;
Result := True;
End;
Function TFilterList.GetFilter(Index: Integer): String;
Var
StartPos, Endpos: Integer;
Begin
If Not GetFilterPos(Index, StartPos, Endpos) Then Exit;
Result := Copy(Filters, StartPos, Endpos - StartPos + 1);
End;
Procedure TFilterList.SetFilter(Index: Integer; Value: String);
Begin
End;
Function TFilterList.GetFilterDescript(Index: Integer): String;
Var
s: String;
StartPos, Endpos: Integer;
Begin
If Not GetFilterPos(Index, StartPos, Endpos) Then Exit;
s := Copy(Filters, StartPos, Endpos - StartPos);
StartPos := Pos('|', s);
Result := Copy(s, 1, StartPos - 1);
End;
Procedure TFilterList.SetFilterDescript(Index: Integer; Value: String);
Begin
End;
Function TFilterList.GetFilterExt(Index: Integer): String;
Var
s: String;
StartPos, Endpos: Integer;
Begin
If Not GetFilterPos(Index, StartPos, Endpos) Then Exit;
s := Copy(Filters, StartPos, Endpos - StartPos + 1);
StartPos := Pos('|', s);
Result := Copy(s, StartPos + 1, Length(s));
End;
Procedure TFilterList.SetFilterExt(Index: Integer; Value: String);
Begin
End;
Procedure TFilterList.Add(Const aDescript, aExt: String);
Begin
Filters := Filters + '|' + aDescript + '|' + aExt;
End;
Procedure TFilterList.AddFilter(Const aFilter: String);
Begin
Filters := Filters + '|' + aFilter;
End;
Procedure TFilterList.Delete(Const AIndex: Integer);
Var
StartPos, Endpos: Integer;
Begin
If Not GetFilterPos(AIndex, StartPos, Endpos) Then Exit;
Filters := Copy(Filters, 1, StartPos - 1) + Copy(Filters, Endpos + 2, Length(Filters));
End;
Function TFilterList.Count: Integer;
Begin
Result := (SeperatorCount(Filters, '|') + 1) Div 2;
End;
{TFilterList -------END}
Procedure TEditorDataModule.EnumerateExporters(Const Items: TStrings; Var Filter: String);
Var
i: Integer;
Begin
Items.Clear;
// Items.Add('(无)');
Filter := '';
For i := 0 To ComponentCount - 1 Do
If Components[i] Is TSynCustomExporter Then Begin
Items.Add((Components[i] As TSynCustomExporter).FormatName);
If (Components[i] As TSynCustomExporter).DefaultFilter <> '' Then Begin
If Filter <> '' Then Filter := Filter + '|';
Filter := Filter + (Components[i] As TSynCustomExporter).DefaultFilter;
End;
End;
{$IFDEF debug}
For i := 0 To Items.Count - 1 Do
{SendDebug proc provide by GExperts}
SendDebug(IntToStr(i) + ':' + Items[i]);
{$ENDIF}
End;
Procedure AddExt(Var Source: String; Exts: String);
//trim Duplicates Ext and add Ext to Source
Var
SepPos: Integer;
s: String;
Begin
// i := 1;
SepPos := SeperatorCount(Exts, ';');
If (SepPos = 0) And (Pos(UpperCase(Exts), UpperCase(Source)) <= 0) Then
Source := Source + ';' + Exts
Else Begin
SepPos := 0;
Repeat
s := '';
Inc(SepPos);
While (SepPos <= Length(Exts)) And (Exts[SepPos] <> ';') Do Begin
s := s + Exts[SepPos];
Inc(SepPos);
End;
If (Pos(UpperCase(s), UpperCase(Source)) <= 0) Then
Source := Source + ';' + s;
Until SepPos > Length(Exts);
End;
End;
Procedure TEditorDataModule.EnumerateHighlighters(Const Items: TStrings; Var Filter: String);
Var
i: Integer;
AllSuportedExt: String;
FilterList: TFilterList;
Begin
Items.Clear;
Items.Add(tran.TMsg(SNone));
Filter := '';
AllSuportedExt := '';
For i := 0 To ComponentCount - 1 Do
If Components[i] Is TSynCustomHighlighter Then Begin
Items.AddObject((Components[i] As TSynCustomHighlighter).LanguageName, Components[i]);
If (Components[i] As TSynCustomHighlighter).DefaultFilter <> '' Then Begin
If Filter <> '' Then Filter := Filter + '|';
Filter := Filter + (Components[i] As TSynCustomHighlighter).DefaultFilter;
End;
End;
FilterList := TFilterList.Create;
Try
FilterList.Filters := Filter;
//FilterList.DeleteDuplicatesExt;
AllSuportedExt := FilterList.Extension[0];
For i := 1 To FilterList.Count - 1 Do Begin
AddExt(AllSuportedExt, FilterList.Extension[i]);
//s := FilterList.Extension[i];
//if Pos(UpperCase(s), UpperCase(AllSuportedExt)) <= 0 then
//AllSuportedExt := AllSuportedExt +';'+ s;
End;
Finally
FilterList.Free;
End; //try
If Filter <> '' Then Filter := Filter + '|';
//Delete(AllSuportedExt, Length(AllSuportedExt), 1);
AllSuportedExt := tran.TMsg(sAllSuportFile) + '|' + AllSuportedExt;
Filter := AllSuportedExt + '|' + Filter + tran.TMsg(sAllFile) + ' (*.*)|*.*';
End;
Function FormatAttrib(Attrib: TSynHighlighterAttributes): String;
Begin
Result := IntToHex(Attrib.BackGround, 8) + ':' +
IntToHex(Attrib.ForegRound, 8) + ':';
If (FsBOld In Attrib.Style) Then
Result := Result + '1:'
Else
Result := Result + '0:';
If (FsItalic In Attrib.Style) Then
Result := Result + '1:'
Else
Result := Result + '0:';
If (FsUnderLine In Attrib.Style) Then
Result := Result + '1:'
Else
Result := Result + '0:';
If (FsStrikeOut In Attrib.Style) Then
Result := Result + '1'
Else
Result := Result + '0';
End;
Procedure ParseAttr(Value: String; Attrib: TSynHighlighterAttributes);
Var
P: Integer;
Begin
P := Pos(':', Value);
If P > 0 Then
Attrib.BackGround := StrToIntDef('$' + Copy(Value, 1, P - 1), clWindow);
Delete(Value, 1, P);
P := Pos(':', Value);
If P > 0 Then
Attrib.ForegRound := StrToIntDef('$' + Copy(Value, 1, P - 1), clWindowText);
Delete(Value, 1, P);
Attrib.Style := [];
P := Pos(':', Value);
If P > 0 Then
If (StrToIntDef('$' + Copy(Value, 1, P - 1), 0) > 0) Then
Attrib.Style := Attrib.Style + [FsBOld];
Delete(Value, 1, P);
P := Pos(':', Value);
If P > 0 Then
If (StrToIntDef('$' + Copy(Value, 1, P - 1), 0) > 0) Then
Attrib.Style := Attrib.Style + [FsItalic];
Delete(Value, 1, P);
P := Pos(':', Value);
If P > 0 Then
If (StrToIntDef('$' + Copy(Value, 1, P - 1), 0) > 0) Then
Attrib.Style := Attrib.Style + [FsUnderLine];
Delete(Value, 1, P);
P := Pos(':', Value);
If P > 0 Then
If (StrToIntDef('$' + Copy(Value, 1, P - 1), 0) > 0) Then
Attrib.Style := Attrib.Style + [FsStrikeOut];
Delete(Value, 1, P);
End;
Procedure TEditorDataModule.LoadSettings(Const FileName: TFileName);
Var
Ini: TIniFile;
I, J: Integer;
Attr: String;
Begin
Ini := TIniFile.Create(FileName);
Try
For i := 0 To ComponentCount - 1 Do Begin
If Components[i] Is TSynCustomHighlighter Then Begin
With Components[i] As TSynCustomHighlighter Do Begin
DefaultFilter := Ini.ReadString(LanguageName, 'DefaultFilter', DefaultFilter);
For J := 0 To AttrCount - 1 Do Begin
Attr := Ini.ReadString(LanguageName, Attribute[J].Name, FormatAttrib(Attribute[J]));
ParseAttr(Attr, Attribute[J]);
End;
End;
End;
End;
With frmJediEdit Do Begin
ViewStatusbar.Checked := Ini.ReadBool(ClassName, 'ViewStatusbar_Checked', ViewStatusbar.Checked);
ViewToolbar.Checked := Ini.ReadBool(ClassName, 'ViewToolbar_Checked', ViewToolbar.Checked);
MRUManager.SeparateSize := Ini.ReadInteger(ClassName, 'MRUManager_SeparateSize', MRUManager.SeparateSize);
End;
With dlgOption Do Begin
cbAutoIndent.Checked := Ini.ReadBool(secEditor, 'AutoIndent', True);
cbDragDropEditing.Checked := Ini.ReadBool(secEditor, 'DragDropEditing', True);
cbDropFiles.Checked := Ini.ReadBool(secEditor, 'DropFiles', True);
cbHalfPageScroll.Checked := Ini.ReadBool(secEditor, 'HalfPageScroll', False);
cbScrollPastEol.Checked := Ini.ReadBool(secEditor, 'ScrollPastEol', True);
cbTabsToSpaces.Checked := Ini.ReadBool(secEditor, 'TabsToSpaces', True);
cbTabsToSpacesClick(Nil);
cbSmartTabs.Checked := Ini.ReadBool(secEditor, 'SmartTabs', True);
cboFontName.FontName := Ini.ReadString(secEditor, 'FontName', cboFontName.FontName);
edtFontSize.Value := Ini.ReadInteger(secEditor, 'FontSize', edtFontSize.AsInteger);
cboFontColor.ColorValue := Ini.ReadInteger(secEditor, 'FontColor', cboFontColor.ColorValue);
cboBackColor.ColorValue := Ini.ReadInteger(secEditor, 'BackColor', cboBackColor.ColorValue);
cboDateTimeFormat.Text := Ini.ReadString(secEditor, 'DateTimeFormat', cboDateTimeFormat.Text);
edtUndoCount.Value := Ini.ReadInteger(secEditor, 'MaxUndo', edtUndoCount.AsInteger);
chkUndoAfterSave.Checked := Ini.ReadBool(secEditor, 'UndoAfterSaved', chkUndoAfterSave.Checked);
chkAllowDocking.Checked := Ini.ReadBool(secEditor, 'AllowDocking', chkAllowDocking.Checked);
chkAutoSave.Checked := Ini.ReadBool(secEditor, 'AutoSave', chkAutoSave.Checked);
edtSaveSeconds.Value := Ini.ReadInteger(secEditor, 'AutoSaveInterval', edtSaveSeconds.AsInteger);
chkAutosaveClick(Nil);
chkBackupFile.Checked := Ini.ReadBool(secEditor, 'AutoBackup', chkBackupFile.Checked);
chkOverwriteBackup.Checked := Ini.ReadBool(secEditor, 'OverwriteBackup', chkOverwriteBackup.Checked);
chkBackupFileClick(Nil);
chkShowCurrentLine.Checked := Ini.ReadBool(secEditor, 'ShowCurrentLine', chkShowCurrentLine.Checked);
ShowSpecialLineColor := chkShowCurrentLine.Checked;
cboCurrentLineColor.ColorValue := Ini.ReadInteger(secEditor, 'CurrentLineColor', cboCurrentLineColor.ColorValue);
chkShowCurrentLineClick(Nil);
chkLastOpen.Checked := Ini.ReadBool(secEditor, 'KeepLastOpen', chkLastOpen.Checked);
chkShowSplash.Checked := Ini.ReadBool(secEditor, 'ShowSplash', chkShowSplash.Checked);
edtSpaces.Value := Ini.ReadInteger(secEditor, 'TabSpaces', edtSpaces.AsInteger);
//CurrentLan := INI.ReadString( secEditor, 'DefaultLanguage', CurrentLan );
hkCodeTemplate.Hotkey := TextToShortCut(
Ini.ReadString(secCodeInsight, 'TemplateCodeHotkey', 'Ctrl+J'));
scAutoCompletion := hkCodeTemplate.Hotkey;
cbShowLineNumbers.Checked := Ini.ReadBool(secGutter, 'ShowLineNumbers', False);
cbxGutterSize.Text := Ini.ReadString(secGutter, 'GutterSize', '30');
cbGutterVisible.Checked := Boolean(StrToInt(cbxGutterSize.Text));
{Navigate Keys Commands:}
nkcJumpUpPro := TextToShortcut(
Ini.ReadString(secNavKeys, 'JumpUpProShortcut', 'Ctrl+PgUp'));
nkcJumpDnPro := TextToShortcut(
Ini.ReadString(secNavKeys, 'JumpDnProShortcut', 'Ctrl+PgDn'));
nkcProcMakePro := TextToShortcut(
Ini.ReadString(secNavKeys, 'MakeProcShortcut', 'Ctrl+Shift+C'));
nkcCollaspeNext := TextToShortcut(
Ini.ReadString(secNavKeys, 'CollaspeNextShortcut', 'Ctrl+]'));
nkcCollaspePrev := TextToShortcut(
Ini.ReadString(secNavKeys, 'CollaspePrevShortcut', 'Ctrl+['));
End; //with
Finally
Ini.Free;
End;
End;
Procedure TEditorDataModule.StoreSettings(Const FileName: TFileName);
Var
Ini: TIniFile;
I, J, X, Y: Integer;
Bookmarks: TBookMarksSet;
s: String;
Begin
Ini := TIniFile.Create(FileName);
Try
For i := 0 To ComponentCount - 1 Do
If Components[i] Is TSynCustomHighlighter Then
With Components[i] As TSynCustomHighlighter Do Begin
Ini.WriteString(LanguageName, 'DefaultFilter', DefaultFilter);
For J := 0 To AttrCount - 1 Do
Ini.WriteString(LanguageName, Attribute[J].Name,
FormatAttrib(Attribute[J]));
End; //with
With frmJediEdit Do Begin
Ini.WriteBool(ClassName, 'ViewStatusbar_Checked', ViewStatusbar.Checked);
Ini.WriteBool(ClassName, 'ViewToolbar_Checked', ViewToolbar.Checked);
Ini.WriteInteger(ClassName, 'MRUManager_SeparateSize', MRUManager.SeparateSize);
End;
With dlgOption Do Begin
Ini.WriteBool(secEditor, 'AutoIndent', cbAutoIndent.Checked);
Ini.WriteBool(secEditor, 'DragDropEditing', cbDragDropEditing.Checked);
Ini.WriteBool(secEditor, 'DropFiles', cbDropFiles.Checked);
Ini.WriteBool(secEditor, 'HalfPageScroll', cbHalfPageScroll.Checked);
Ini.WriteBool(secEditor, 'ScrollPastEol', cbScrollPastEol.Checked);
Ini.WriteBool(secEditor, 'TabsToSpaces', cbTabsToSpaces.Checked);
Ini.WriteBool(secEditor, 'SmartTabs', cbSmartTabs.Checked);
Ini.WriteString(secEditor, 'FontName', cboFontName.FontName);
Ini.WriteInteger(secEditor, 'FontSize', edtFontSize.AsInteger);
Ini.WriteInteger(secEditor, 'FontColor', cboFontColor.ColorValue);
Ini.WriteInteger(secEditor, 'BackColor', cboBackColor.ColorValue);
Ini.WriteString(secEditor, 'DateTimeFormat', cboDateTimeFormat.Text);
Ini.WriteInteger(secEditor, 'MaxUndo', edtUndoCount.AsInteger);
Ini.WriteBool(secEditor, 'UndoAfterSaved', chkUndoAfterSave.Checked);
Ini.WriteBool(secEditor, 'AllowDocking', chkAllowDocking.Checked);
Ini.WriteBool(secEditor, 'AutoSave', chkAutoSave.Checked);
Ini.WriteInteger(secEditor, 'AutoSaveInterval', edtSaveSeconds.AsInteger);
chkAutosaveClick(Nil);
Ini.WriteBool(secEditor, 'AutoBackup', chkBackupFile.Checked);
Ini.WriteBool(secEditor, 'OverwriteBackup', chkOverwriteBackup.Checked);
Ini.WriteBool(secEditor, 'ShowCurrentLine', chkShowCurrentLine.Checked);
Ini.WriteInteger(secEditor, 'CurrentLineColor', cboCurrentLineColor.ColorValue);
chkShowCurrentLineClick(Nil);
Ini.WriteBool(secEditor, 'KeepLastOpen', chkLastOpen.Checked);
Ini.WriteBool(secEditor, 'ShowSplash', chkShowSplash.Checked);
Ini.WriteInteger(secEditor, 'TabSpaces', edtSpaces.AsInteger);
Ini.WriteString('TfrmJediEdit', 'DefaultLanguage', CurrentLan);
Ini.WriteString(secCodeInsight, 'TemplateCodeHotkey', ShortCutToText(hkCodeTemplate.Hotkey));
Ini.WriteBool(secGutter, 'ShowLineNumbers', cbShowLineNumbers.Checked);
Ini.WriteString(secGutter, 'GutterSize', cbxGutterSize.Text);
{Navigate Keys Commands:}
Ini.WriteString(secNavKeys, 'JumpUpProShortcut', ShortCutToText(nkcJumpUpPro));
Ini.WriteString(secNavKeys, 'JumpDnProShortcut', ShortCutToText(nkcJumpDnPro));
Ini.WriteString(secNavKeys, 'MakeProcShortcut', ShortCutToText(nkcProcMakePro));
Ini.WriteString(secNavKeys, 'CollaspeNextShortcut', ShortCutToText(nkcCollaspeNext));
Ini.WriteString(secNavKeys, 'CollaspePrevShortcut', ShortCutToText(nkcCollaspePrev));
With frmJediEdit Do Begin
If KeepLastOpen Then Begin
Ini.EraseSection(secLastOpen);
Ini.WriteInteger(secLastOpen, 'FileOpenNumber', EditorCount);
For I := 0 To EditorCount - 1 Do Begin
Ini.WriteString(secLastOpen, 'LastFile_' + IntToStr(I), Editor[I].FileName);
Ini.WriteInteger(secLastOpen, 'LastFile_' + IntToStr(I) + 'XPos', Editor[I].CaretX);
Ini.WriteInteger(secLastOpen, 'LastFile_' + IntToStr(I) + 'YPos', Editor[I].CaretY);
{remember bookmarks}
Bookmarks := [];
s := '';
For j := 0 To 9 Do Begin
If Editor[I].GetBookmark(J, x, y) Then Begin
Include(Bookmarks, j);
s := s + ',' + IntToStr(x) + ',' + IntToStr(y);
End;
End;
Delete(s, 1, 1);
Ini.WriteInteger(secLastOpen, 'LastFile_' + IntToStr(I) + 'Marks', Word(Bookmarks));
Ini.WriteString(secLastOpen, 'LastFile_' + IntToStr(I) + 'MarksPos', s);
End;
End;
End;
End;
Finally
Ini.Free;
End;
End;
Function GetFileName: String;
Begin
Result := '';
If frmJediEdit.CurrentEditor <> Nil Then Result := frmJediEdit.CurrentEditor.FileName
End;
Function GetReplaceString(StVar: String): String;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -