Ignore:
Timestamp:
Jul 12, 2012, 8:21:21 AM (12 years ago)
Author:
chronos
Message:
  • Added: Clipboard manipulation support in source code form.
  • Modified: Moved code which belongs to UFormSourceCode from UFormMain.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormMain.pas

    r46 r47  
    2727    ABreakpointToggle: TAction;
    2828    AViewCompilers: TAction;
    29     AGenerateNumber: TAction;
    30     AShrinkSource: TAction;
    31     AFormatSource: TAction;
    3229    AOptions: TAction;
    3330    AProgramStepOut: TAction;
     
    119116    procedure ABreakpointToggleExecute(Sender: TObject);
    120117    procedure AExitExecute(Sender: TObject);
    121     procedure AFormatSourceExecute(Sender: TObject);
    122     procedure AGenerateNumberExecute(Sender: TObject);
    123118    procedure AOptionsExecute(Sender: TObject);
    124119    procedure AProgramCompileExecute(Sender: TObject);
     
    138133    procedure AShowSourcePositionExecute(Sender: TObject);
    139134    procedure AShowTargetPositionExecute(Sender: TObject);
    140     procedure AShrinkSourceExecute(Sender: TObject);
    141135    procedure AViewCompilersExecute(Sender: TObject);
    142136    procedure AViewInterpretterExecute(Sender: TObject);
     
    145139    procedure FormDestroy(Sender: TObject);
    146140    procedure FormShow(Sender: TObject);
    147     procedure MemoSourceChange(Sender: TObject);
    148     procedure MemoSourceKeyDown(Sender: TObject; var Key: Word;
    149       Shift: TShiftState);
    150     procedure MemoSourceKeyPress(Sender: TObject; var Key: char);
    151     procedure MemoSourceKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState
    152       );
    153     procedure MemoSourceMouseDown(Sender: TObject; Button: TMouseButton;
    154       Shift: TShiftState; X, Y: Integer);
    155141    procedure TimerRefreshTimer(Sender: TObject);
    156142  private
     
    193179
    194180resourcestring
    195   SEnterNumber = 'Enter number';
    196   SNumberGeneration = 'Number generation';
    197181  SProgramExited = 'Program exited';
    198182  SProgramStarted = 'Program started';
     
    215199end;
    216200
    217 procedure TMainForm.MemoSourceChange(Sender: TObject);
    218 begin
    219   Modified := True;
    220   CurrentTarget.Compiled := False;
    221   UpdateInterface;
    222 end;
    223 
    224 procedure TMainForm.MemoSourceKeyDown(Sender: TObject; var Key: Word;
    225   Shift: TShiftState);
    226 begin
    227 end;
    228 
    229 procedure TMainForm.MemoSourceKeyPress(Sender: TObject; var Key: char);
    230 begin
    231 end;
    232 
    233 procedure TMainForm.MemoSourceKeyUp(Sender: TObject; var Key: Word;
    234   Shift: TShiftState);
    235 begin
    236   UpdateStatusBar;
    237 end;
    238 
    239 procedure TMainForm.MemoSourceMouseDown(Sender: TObject; Button: TMouseButton;
    240   Shift: TShiftState; X, Y: Integer);
    241 begin
    242   UpdateStatusBar;
    243 end;
    244 
    245201procedure TMainForm.TimerRefreshTimer(Sender: TObject);
    246202begin
     
    281237  LastOpenedList.AddItem(FileName);
    282238  ProjectFileName := FileName;
    283   UpdateInterface;
    284239  Modified := False;
    285240  CurrentTarget.Compiled := False;
     241  UpdateInterface;
    286242end;
    287243
     
    485441end;
    486442
    487 procedure TMainForm.AShrinkSourceExecute(Sender: TObject);
    488 var
    489   Source: string;
    490   Pos: Integer;
    491   I: Integer;
    492 begin
    493   Source := FormSourceCode.MemoSource.Text;
    494   Pos := 1;
    495   for I := 1 to Length(Source) do begin
    496     if Source[I] > ' ' then begin
    497       Source[Pos] := Source[I];
    498       Inc(Pos);
    499     end;
    500   end;
    501   SetLength(Source, Pos - 1);
    502   FormSourceCode.MemoSource.Text := Source;
    503 end;
    504 
    505443procedure TMainForm.AViewCompilersExecute(Sender: TObject);
    506444begin
     
    521459begin
    522460  Close;
    523 end;
    524 
    525 procedure TMainForm.AFormatSourceExecute(Sender: TObject);
    526 var
    527   Source: string;
    528   NewSource: string;
    529   Indent: Integer;
    530   I: Integer;
    531 const
    532   IndentText = '  ';
    533 begin
    534   Source := FormSourceCode.MemoSource.Text;
    535   NewSource := '';
    536   Indent := 0;
    537   for I := 1 to Length(Source) do begin
    538     if Source[I] = '[' then begin
    539       NewSource := NewSource + LineEnding + DupeString(IndentText, Indent) + Source[I] + LineEnding ;
    540       Inc(Indent);
    541       NewSource := NewSource + DupeString(IndentText, Indent);
    542     end
    543     else if Source[I] = ']' then begin
    544       Dec(Indent);
    545       NewSource := NewSource + LineEnding + DupeString(IndentText, Indent) + Source[I] + LineEnding + DupeString(IndentText, Indent);
    546     end
    547     else if Ord(Source[I]) > $20 then
    548       NewSource := NewSource + Source[I];
    549   end;
    550   FormSourceCode.MemoSource.Text := NewSource;
    551 end;
    552 
    553 procedure TMainForm.AGenerateNumberExecute(Sender: TObject);
    554 var
    555   NumberText: string;
    556   Number: Integer;
    557   I: Integer;
    558 begin
    559   NumberText := InputBox(SNumberGeneration, SEnterNumber, '1');
    560   if TryStrToInt(NumberText, Number) then begin
    561     NumberText := '';
    562     for I := 0 to Number - 1 do
    563       NumberText := NumberText + '+';
    564     FormSourceCode.MemoSource.Text := FormSourceCode.MemoSource.Text + NumberText;
    565   end;
    566461end;
    567462
     
    665560procedure TMainForm.AProjectCloseExecute(Sender: TObject);
    666561begin
     562  if Modified then AProjectSaveAs.Execute;
    667563  AProgramStop.Execute;
    668   Modified := False;
    669564  ProjectFileName := '';
    670565  FormSourceCode.MemoSource.Clear;
     566  Modified := False;
    671567  UpdateInterface;
    672568end;
     
    689585procedure TMainForm.AProjectOpenExecute(Sender: TObject);
    690586begin
     587  AProjectClose.Execute;
    691588  OpenDialog1.FileName := ProjectFileName;
    692589  if OpenDialog1.Execute then begin
Note: See TracChangeset for help on using the changeset viewer.