<commit_before>(*
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.

Copyright (c) <NAME>
*)
unit proc_keysdialog;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, Controls, Forms,
  ATSynEdit_Keymap,
  proc_globdata,
  proc_cmd,
  formkeys;

function DoDialogHotkeys(AKeymap: TATKeymap; ACmd: integer; const ALexerName: string): boolean;
function DoDialogHotkeys(AKeymap: TATKeymap; const AModuleAndMethod: string; const ALexerName: string): boolean;


implementation

function DoDialogHotkeys(AKeymap: TATKeymap; ACmd: integer; const ALexerName: string): boolean;
var
  Form: TfmKeys;
  StrId: string;
  n: integer;
begin
  Result:= false;
  if not AppCommandHasConfigurableHotkey(ACmd) then exit;

  n:= AKeymap.IndexOf(ACmd);
  if n<0 then exit;

  StrId:= DoOps_CommandCode_To_HotkeyStringId(ACmd);

  Form:= TfmKeys.Create(nil);
  try
    Form.Caption:= Form.Caption+' - '+AKeymap[n].Name;
    Form.LexerName:= ALexerName;
    Form.CommandCode:= ACmd;
    Form.Keymap:= AKeymap;
    Form.Keys1:= AKeymap[n].Keys1;
    Form.Keys2:= AKeymap[n].Keys2;

    Result:= Form.ShowModal=mrOk;
    if Result then
    begin
      AKeymap[n].Keys1:= Form.Keys1;
      AKeymap[n].Keys2:= Form.Keys2;
      DoOps_SaveKeyItem(AKeymap[n], StrId,
        ALexerName, Form.chkForLexer.Checked);
    end;
  finally
    Form.Free
  end;
end;


function DoDialogHotkeys(AKeymap: TATKeymap;
  const AModuleAndMethod: string;
  const ALexerName: string): boolean;
var<commit_msg>refac<commit_after>(*
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.

Copyright (c) <NAME>
*)
unit proc_keysdialog;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, Controls, Forms,
  ATSynEdit_Keymap,
  proc_globdata,
  proc_cmd,
  formkeys;

function DoDialogHotkeys(AKeymap: TATKeymap; ACmd: integer; const ALexerName: string): boolean;
function DoDialogHotkeys(AKeymap: TATKeymap; const AModuleAndMethod: string; const ALexerName: string): boolean;


implementation

function DoDialogHotkeys(AKeymap: TATKeymap; ACmd: integer; const ALexerName: string): boolean;
var
  Form: TfmKeys;
  StrId: string;
  bForLexer: boolean;
  n: integer;
begin
  Result:= false;
  if not AppCommandHasConfigurableHotkey(ACmd) then exit;

  n:= AKeymap.IndexOf(ACmd);
  if n<0 then exit;

  StrId:= DoOps_CommandCode_To_HotkeyStringId(ACmd);

  Form:= TfmKeys.Create(nil);
  try
    Form.Caption:= Form.Caption+' - '+AKeymap[n].Name;
    Form.LexerName:= ALexerName;
    Form.CommandCode:= ACmd;
    Form.Keymap:= AKeymap;
    Form.Keys1:= AKeymap[n].Keys1;
    Form.Keys2:= AKeymap[n].Keys2;

    Result:= Form.ShowModal=mrOk;
    if Result then
    begin
      AKeymap[n].Keys1:= Form.Keys1;
      AKeymap[n].Keys2:= Form.Keys2;
      bForLexer:= Form.chkForLexer.Checked;

      DoOps_SaveKeyItem(AKeymap[n], StrId, ALexerName, bForLexer);
    end;
  finally
    Form.Free
  end;
end;


function DoDialogHotkeys(AKeymap: TATKeymap;
  const AModuleAndMethod: string;
  const ALexerName: string): boolean;
var
{'fraction_non_alphanumeric': 0.11175750153092467, 'fraction_numerical': 0.007960808328230252, 'mean_word_length': 4.303571428571429, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4975065', 'n_tokens_mistral': 1288, 'n_tokens_neox': 1222, 'n_words': 303}