Jedi code format: new option to remove comments in the current editor window.

This commit is contained in:
DomingoGP 2024-11-08 19:15:03 +01:00
parent b5e2e98d35
commit 4a2319c986
18 changed files with 101 additions and 1 deletions

View File

@ -46,7 +46,7 @@ uses
// local
EditorConverter, FileConverter, Converter, ConvertTypes,
JcfUIConsts, JcfStringUtils, JcfSettings, fAbout, frFiles,
JcfRegistrySettings, fRegistrySettings;
JcfRegistrySettings, fRegistrySettings, SettingsTypes;
type
@ -77,6 +77,7 @@ type
procedure DoFormatCurrentIDEWindow(Sender: TObject);
procedure DoFormatProject(Sender: TObject);
procedure DoFormatOpen(Sender: TObject);
procedure DoRemoveCommentsInCurrentIDEWindow(Sender: TObject);
procedure DoRegistrySettings(Sender: TObject);
procedure DoFormatSettings(Sender: TObject);
procedure DoAbout(Sender: TObject);
@ -215,6 +216,37 @@ begin
fcEditorConverter.AfterConvert;
end;
procedure TJcfIdeMain.DoRemoveCommentsInCurrentIDEWindow(Sender: TObject);
var
lcCaps : TCapitalisationType;
lbEnabled,lbRemoveComments,lbRemoveWhiteSpace,lbRemoveIndent,lbRebreakLines:boolean;
begin
try
lbEnabled := FormattingSettings.Obfuscate.Enabled;
lcCaps := FormattingSettings.Obfuscate.Caps;
lbRemoveComments := FormattingSettings.Obfuscate.RemoveComments;
lbRemoveWhiteSpace := FormattingSettings.Obfuscate.RemoveWhiteSpace;
lbRemoveIndent := FormattingSettings.Obfuscate.RemoveIndent;
lbRebreakLines := FormattingSettings.Obfuscate.RebreakLines;
FormattingSettings.Obfuscate.Enabled := True;
FormattingSettings.Obfuscate.Caps := ctLeaveAlone;
FormattingSettings.Obfuscate.RemoveComments := True;
FormattingSettings.Obfuscate.RemoveWhiteSpace := False;
FormattingSettings.Obfuscate.RemoveIndent := False;
FormattingSettings.Obfuscate.RebreakLines := False;
DoFormatCurrentIDEWindow(Sender);
finally
//restore settings.
FormattingSettings.Obfuscate.Enabled := lbEnabled;
FormattingSettings.Obfuscate.Caps := lcCaps;
FormattingSettings.Obfuscate.RemoveComments := lbRemoveComments;
FormattingSettings.Obfuscate.RemoveWhiteSpace := lbRemoveWhiteSpace;
FormattingSettings.Obfuscate.RemoveIndent := lbRemoveIndent;
FormattingSettings.Obfuscate.RebreakLines := lbRebreakLines;
end;
end;
procedure TJcfIdeMain.FormatFile(const psFileName: string);
begin

View File

@ -72,6 +72,7 @@ const
FORMAT_CURRENT_NAME = 'jcfCurrentEditorWindow';
FORMAT_PROJECT_MENU_NAME = 'jcfAllFilesinProject';
FORMAT_OPEN_MENU_NAME = 'jcfAllOpenWindows';
FORMAT_REMOVE_COMMENTS_NAME = 'jcfRemoveComments';
FORMAT_SETTINGS_MENU_NAME = 'jcfFormatSettings';
FORMAT_REG_SETTINGS_MENU_NAME = 'jcfRegSettings';
FORMAT_ABOUT_MENU_NAME = 'jcfAbout';
@ -140,6 +141,12 @@ begin
RegisterIDEMenuCommand(fcMainMenu, FORMAT_OPEN_MENU_NAME, FORMAT_OPEN_MENU,
lcJCFIDE.DoFormatOpen);
Key := IDEShortCut(VK_UNKNOWN,[],VK_UNKNOWN, []);
Cmd := RegisterIDECommand(Cat, FORMAT_REMOVE_COMMENTS_NAME, FORMAT_REMOVE_COMMENTS,
Key, lcJCFIDE.DoRemoveCommentsInCurrentIDEWindow);
RegisterIDEMenuCommand(fcMainMenu, FORMAT_REMOVE_COMMENTS_NAME, FORMAT_REMOVE_COMMENTS,
lcJCFIDE.DoRemoveCommentsInCurrentIDEWindow, nil, Cmd);
// settings
SubSection := RegisterIDEMenuSection(fcMainMenu, FORMAT_MENU_SECTION1);
RegisterIDEMenuCommand(SubSection, FORMAT_REG_SETTINGS_MENU_NAME, FORMAT_REG_SETTINGS_MENU,

View File

@ -10,6 +10,7 @@ resourcestring
FORMAT_CURRENT_IDECMD = 'Format code in current editor window';
FORMAT_PROJECT_MENU = '&All Files in Project';
FORMAT_OPEN_MENU = 'All &Open Windows';
FORMAT_REMOVE_COMMENTS = 'Remove comments in current editor window';
FORMAT_SETTINGS_MENU = '&Format Settings ...';
FORMAT_REG_SETTINGS_MENU= 'Global Settings ...';
FORMAT_ABOUT_MENU = '&About ...';

View File

@ -48,6 +48,10 @@ msgstr "&Všechny soubory v Projektu"
msgid "Global Settings ..."
msgstr ""
#: jcfuiconsts.format_remove_comments
msgid "Remove comments in current editor window"
msgstr ""
#: jcfuiconsts.format_settings_menu
#, fuzzy
#| msgid "&Format Settings"

View File

@ -47,6 +47,10 @@ msgstr "&Alle Dateien im Projekt"
msgid "Global Settings ..."
msgstr ""
#: jcfuiconsts.format_remove_comments
msgid "Remove comments in current editor window"
msgstr ""
#: jcfuiconsts.format_settings_menu
#, fuzzy
#| msgid "&Format Settings"

View File

@ -47,6 +47,10 @@ msgstr "Todos los Archivos en el &Proyecto"
msgid "Global Settings ..."
msgstr ""
#: jcfuiconsts.format_remove_comments
msgid "Remove comments in current editor window"
msgstr ""
#: jcfuiconsts.format_settings_menu
#, fuzzy
#| msgid "&Format Settings"

View File

@ -49,6 +49,10 @@ msgstr "Tous les fichiers d&ans le projet"
msgid "Global Settings ..."
msgstr ""
#: jcfuiconsts.format_remove_comments
msgid "Remove comments in current editor window"
msgstr ""
#: jcfuiconsts.format_settings_menu
#, fuzzy
#| msgid "&Format Settings"

View File

@ -49,6 +49,10 @@ msgstr "Minden fájl a projektben"
msgid "Global Settings ..."
msgstr ""
#: jcfuiconsts.format_remove_comments
msgid "Remove comments in current editor window"
msgstr ""
#: jcfuiconsts.format_settings_menu
#, fuzzy
#| msgid "&Format Settings"

View File

@ -50,6 +50,10 @@ msgstr "Tutti i file nel &progetto"
msgid "Global Settings ..."
msgstr ""
#: jcfuiconsts.format_remove_comments
msgid "Remove comments in current editor window"
msgstr ""
#: jcfuiconsts.format_settings_menu
#, fuzzy
#| msgid "&Format Settings"

View File

@ -49,6 +49,10 @@ msgstr "プロジェクト内すべてのファイル(&A)"
msgid "Global Settings ..."
msgstr ""
#: jcfuiconsts.format_remove_comments
msgid "Remove comments in current editor window"
msgstr ""
#: jcfuiconsts.format_settings_menu
#, fuzzy
#| msgid "&Format Settings"

View File

@ -49,6 +49,10 @@ msgstr "Visuose projekto &failuose"
msgid "Global Settings ..."
msgstr ""
#: jcfuiconsts.format_remove_comments
msgid "Remove comments in current editor window"
msgstr ""
#: jcfuiconsts.format_settings_menu
#, fuzzy
#| msgid "&Format Settings"

View File

@ -50,6 +50,10 @@ msgstr "Wszystkie pliki projektu"
msgid "Global Settings ..."
msgstr ""
#: jcfuiconsts.format_remove_comments
msgid "Remove comments in current editor window"
msgstr ""
#: jcfuiconsts.format_settings_menu
#, fuzzy
#| msgid "&Format Settings"

View File

@ -33,6 +33,10 @@ msgstr ""
msgid "Global Settings ..."
msgstr ""
#: jcfuiconsts.format_remove_comments
msgid "Remove comments in current editor window"
msgstr ""
#: jcfuiconsts.format_settings_menu
msgid "&Format Settings ..."
msgstr ""

View File

@ -49,6 +49,10 @@ msgstr "Todos os &Arquivos no Projeto"
msgid "Global Settings ..."
msgstr ""
#: jcfuiconsts.format_remove_comments
msgid "Remove comments in current editor window"
msgstr ""
#: jcfuiconsts.format_settings_menu
#, fuzzy
#| msgid "&Format Settings"

View File

@ -47,6 +47,10 @@ msgstr "Все файлы &проекта"
msgid "Global Settings ..."
msgstr "Глобальные параметры ..."
#: jcfuiconsts.format_remove_comments
msgid "Remove comments in current editor window"
msgstr ""
#: jcfuiconsts.format_settings_menu
msgid "&Format Settings ..."
msgstr "П&араметры форматирования ..."

View File

@ -47,6 +47,10 @@ msgstr "Projedeki &Tüm Dosyalar"
msgid "Global Settings ..."
msgstr "Genel Ayarlar ..."
#: jcfuiconsts.format_remove_comments
msgid "Remove comments in current editor window"
msgstr ""
#: jcfuiconsts.format_settings_menu
msgid "&Format Settings ..."
msgstr "For&mat Ayarları ..."

View File

@ -52,6 +52,10 @@ msgstr "Всі &файли у проєкті"
msgid "Global Settings ..."
msgstr ""
#: jcfuiconsts.format_remove_comments
msgid "Remove comments in current editor window"
msgstr ""
#: jcfuiconsts.format_settings_menu
#, fuzzy
#| msgid "&Format Settings"

View File

@ -50,6 +50,10 @@ msgstr "项目中的所有文件(&A)"
msgid "Global Settings ..."
msgstr ""
#: jcfuiconsts.format_remove_comments
msgid "Remove comments in current editor window"
msgstr ""
#: jcfuiconsts.format_settings_menu
#, fuzzy
#| msgid "&Format Settings"