⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 syneditmiscclasses.pas

📁 SynEditStudio delphi 代码编辑器
💻 PAS
📖 第 1 页 / 共 5 页
字号:
  Key: Word;
  Shift: TShiftState;
  MaybeInvalidKey: THKInvalidKey;
begin
  ShortCutToKey(Value, Key, Shift);

  MaybeInvalidKey := ShiftStateToTHKInvalidKey(Shift);
  if MaybeInvalidKey in FInvalidKeys then
    Shift := ModifiersToShiftState(FModifiers);

  FHotKey := ShortCut(Key, Shift);
  Text := ShortCutToTextEx(Key, Shift);
  Invalidate;
  if not Visible then
    SetCaretPos(BorderWidth + 1 + Canvas.TextWidth(Text), BorderWidth + 1);
end;

procedure TSynHotKey.SetInvalidKeys(const Value: THKInvalidKeys);
begin
  FInvalidKeys := Value;
  SetHotKey(FHotKey);
end;

procedure TSynHotKey.SetModifiers(const Value: THKModifiers);
begin
  FModifiers := Value;
  SetHotKey(FHotKey);
end;

{$IFDEF SYN_CLX}
function TSynHotKey.WidgetFlags: Integer;
begin
  Result := inherited WidgetFlags or Integer(WidgetFlags_WRepaintNoErase);
end;
{$ENDIF}

{$IFNDEF SYN_CLX}
procedure TSynHotKey.WMGetDlgCode(var Message: TMessage);
begin
  Message.Result := DLGC_WANTTAB or DLGC_WANTARROWS;
end;

procedure TSynHotKey.WMKillFocus(var Msg: TWMKillFocus);
begin
  DestroyCaret;
end;

procedure TSynHotKey.WMSetFocus(var Msg: TWMSetFocus);
begin
  Canvas.Font := Font;
  CreateCaret(Handle, 0, 1, -Canvas.Font.Height + 2);
  SetCaretPos(BorderWidth + 1 + Canvas.TextWidth(Text), BorderWidth + 1);
  ShowCaret(Handle);
end;
{$ENDIF}

{ TSynRightEdge }

procedure TSynRightEdge.Assign(Source: TPersistent);
begin
  if (Source <> nil) and (Source is TSynRightEdge) then
    with Source as TSynRightEdge do
    begin
      self.FVisible := FVisible;
      self.FPosition := FPosition;
      self.FColor := FColor;
      self.FStyle := FStyle;
      self.MouseMove := FMouseMove;
      self.DoChange;
    end
  else
    inherited Assign(Source);
end;

constructor TSynRightEdge.Create;
begin
  FVisible:= true;
  FPosition:= 80;
  FColor:= clSilver;
  FStyle:= psSolid;
  FMouseMove := False;
end;

procedure TSynRightEdge.DoChange;
begin
  IF Assigned(FOnChange) then FOnChange(self);
end;

procedure TSynRightEdge.SetColor(const Value: TColor);
begin
  if FColor <> value then
  begin
    FColor := Value;
    Dochange
  end;
end;

procedure TSynRightEdge.SetMouseMove(const Value: Boolean);
begin
  FMouseMove := Value;
end;

procedure TSynRightEdge.SetPosition(const Value: Integer);
begin
  if FPosition <> value then
  begin
    FPosition := Value;
    Dochange
  end;
end;

procedure TSynRightEdge.SetStyle(const Value: TPenStyle);
begin
  if FStyle <> value then
  begin
    FStyle := Value;
    Dochange
  end;
end;

procedure TSynRightEdge.SetVisible(const Value: Boolean);
begin
  if FVisible <> value then
  begin
    FVisible := Value;
    Dochange
  end;
end;


{ TSynActiveLine }

procedure TSynActiveLine.Assign(Source: TPersistent);
begin
  if (Source <> nil) and (Source is TSynActiveLine) then
    with Source as TSynActiveLine do
    begin
      self.FBackground := FBackground;
      self.FForeground := FForeground;
      self.FVisible := FVisible;
      self.FIndicator.Assign(FIndicator);
      self.DoChange(self);
    end
  else
    inherited Assign(Source);
end;

constructor TSynActiveLine.Create;
begin
  FVisible := true;
  FBackground := clYellow;
  FForeground := clNavy;
  FIndicator := TSynGlyph.Create(0, '', 0);
  FIndicator.OnChange := DoChange;
end;

destructor TSynActiveLine.Destroy;
begin
  FIndicator.Free;
  inherited;
end;

procedure TSynActiveLine.DoChange(Sender : TObject);
begin
  IF Assigned(FOnChange) then FOnChange(Sender);
end;

procedure TSynActiveLine.SetBackground(const Value: TColor);
begin
  if FBackground <> value then
  begin
    FBackground := Value;
    Dochange(self);
  end;
end;

procedure TSynActiveLine.SetForeground(const Value: TColor);
begin
  if FForeground <> value then
  begin
    FForeground := Value;
    Dochange(self);
  end;
end;

procedure TSynActiveLine.SetIndicator(const Value: TSynGlyph);
begin
  FIndicator.Assign(Value);
end;

procedure TSynActiveLine.SetVisible(const Value: boolean);
begin
  if FVisible <> value then
  begin
    FVisible := Value;
    Dochange(self);
  end;
end;


{ TSynLineDivider }

procedure TSynLineDivider.Assign(Source: TPersistent);
begin
  if (Source <> nil) and (Source is TSynLineDivider) then
    with Source as TSynLineDivider do
    begin
      self.FColor := FColor;
      self.FStyle := FStyle;
      self.FVisible := FVisible;
      self.DoChange;
    end
  else
    inherited Assign(Source);
end;

constructor TSynLineDivider.Create;
begin
  FVisible:= false;
  FColor:= clRed;
  FStyle:= psSolid;
end;

procedure TSynLineDivider.DoChange;
begin
  IF Assigned(FOnChange) then FOnChange(self);
end;

procedure TSynLineDivider.SetColor(const Value: TColor);
begin
  if FColor <> value then
  begin
    FColor := Value;
    Dochange
  end;
end;

procedure TSynLineDivider.SetStyle(const Value: TPenStyle);
begin
  if FStyle <> value then
  begin
    FStyle := Value;
    Dochange
  end;
end;

procedure TSynLineDivider.SetVisible(const Value: boolean);
begin
  if FVisible <> value then
  begin
    FVisible := Value;
    Dochange
  end;
end;

{ TSynWordWrap }

procedure TSynWordWrap.Assign(Source: TPersistent);
begin
  if (Source <> nil) and (Source is TSynWordWrap) then
    with Source as TSynWordWrap do
    begin
      self.FEnabled := FEnabled;
      self.FPosition := FPosition;
      self.FStyle := FStyle;
      self.FIndicator.Assign(FIndicator);
      self.DoChange(self);
    end
  else
    inherited Assign(Source);
end;

constructor TSynWordWrap.Create;
begin
  FEnabled := false;
  FPosition:= 80;
  FIndicator := TSynGlyph.Create(HINSTANCE, 'SynEditWrapped', clLime);
  FIndicator.OnChange := DoChange;
  FStyle := wwsClientWidth;
end;

destructor TSynWordWrap.Destroy;
begin
  FIndicator.Free;
  inherited;
end;

procedure TSynWordWrap.DoChange(Sender: TObject);
begin
  if Assigned(fOnChange) then fOnChange(Sender);
end;

procedure TSynWordWrap.SetEnabled(const Value: Boolean);
begin
  if FEnabled <> value then
  begin
    FEnabled := Value;
    Dochange(self);
  end;
end;

procedure TSynWordWrap.SetIndicator(const Value: TSynGlyph);
begin
  FIndicator.Assign(Value);
end;

procedure TSynWordWrap.SetPosition(const Value: Integer);
begin
  if FPosition <> value then
  begin
    FPosition := Value;
    Dochange(self);
  end;
end;

procedure TSynWordWrap.SetStyle(const Value: TSynWordWrapStyle);
begin
  if FStyle <> value then
  begin
    FStyle := Value;
    Dochange(self);
  end;
end;

{$IFNDEF SYN_CLX}
  {$IFNDEF SYN_COMPILER_4_UP}

{ TBetterRegistry }

function TBetterRegistry.OpenKeyReadOnly(const Key: string): Boolean;

  function IsRelative(const Value: string): Boolean;
  begin
    Result := not ((Value <> '') and (Value[1] = '\'));
  end;

var
  TempKey: HKey;
  S: string;
  Relative: Boolean;
begin
  S := Key;
  Relative := IsRelative(S);

  if not Relative then Delete(S, 1, 1);
  TempKey := 0;
  Result := RegOpenKeyEx(GetBaseKey(Relative), PChar(S), 0,
      KEY_READ, TempKey) = ERROR_SUCCESS;
  if Result then
  begin
    if (CurrentKey <> 0) and Relative then S := CurrentPath + '\' + S;
    ChangeKey(TempKey, S);
  end;
end; { TBetterRegistry.OpenKeyReadOnly }

  {$ENDIF SYN_COMPILER_4_UP}
{$ENDIF SYN_CLX}

{ TSynEditScrollBar }

procedure TSynEditScrollBar.Assign(Source: TPersistent);
begin
  IF Source is TSynEditScrollBar then
  begin
    with TSynEditScrollBar(Source) do
    begin
      Self.FOnGetScrollInfo := FOnGetScrollInfo;
      Self.FOnSetScrollInfo := FOnSetScrollInfo;
      Self.FOnShowScrollBar := FOnShowScrollBar;
      Self.FOnEnabledScrollBar := FOnEnabledScrollBar;
    end;
  end else inherited;
end;

destructor TSynEditScrollBar.Destroy;
begin
  If FScrollBars <> nil then
  begin
    If FScrollBars.FHorizontal = self then
       FScrollBars.FHorizontal := nil;
    If FScrollBars.FVertical = self then
       FScrollBars.FVertical := nil;
  end;
  inherited;
end;

function TSynEditScrollBar.DoEnabledScrollBar(const sbArrows: Integer): Boolean;
begin
  result := False;
  if Assigned(FOnEnabledScrollBar) then
    result := FOnEnabledScrollBar(sbArrows)
end;

function TSynEditScrollBar.DoGetScrollInfo(
  var ScrollInfo: TScrollInfo): Boolean;
begin
  result := False;
  if Assigned(FOnGetScrollInfo) then
    result := FOnGetScrollInfo(ScrollInfo)
end;

function TSynEditScrollBar.DoSetScrollInfo(const ScrollInfo: TScrollInfo;
  Redraw: Boolean): Integer;
begin
  result := 0;
  if Assigned(FOnSetScrollInfo) then
    result := FOnSetScrollInfo(ScrollInfo, Redraw)
end;

function TSynEditScrollBar.DoShowScrollBar(const sbShow: Boolean): Boolean;
begin
  result := False;
  if Assigned(FOnShowScrollBar) then
    result := FOnShowScrollBar(sbShow)
end;

{ TSynScrollBars }

procedure TSynScrollBars.SetHorizontal(const Value: TSynEditScrollBar);
begin
  FHorizontal := Value;
  if FHorizontal <> nil then
    FHorizontal.FScrollBars := self;
end;

procedure TSynScrollBars.SetScrollBars(const Value: TScrollStyle);
begin
  if FScrollBars <> Value then
  begin
    FScrollBars := Value;
    doChange;
  end;
end;

procedure TSynScrollBars.SetVertical(const Value: TSynEditScrollBar);
begin
  FVertical := Value;
  if FVertical <> nil then
    FVertical.FScrollBars := self;
end;

procedure TSynScrollBars.SetStyle(const Value: TScrollBarsStyle);
begin
  if FStyle <> Value then
  begin
    FStyle := Value;
    doChange;
  end;
end;

procedure TSynScrollBars.doChange;
begin
  if Assigned(fOnChange) then fOnChange(Self);
end;

proc

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -