Changeset 143 for trunk/Forms


Ignore:
Timestamp:
Mar 8, 2022, 10:55:43 AM (3 years ago)
Author:
chronos
Message:
  • Added: Action to generate text as brainfuck code.
  • Modified: Used loop in number generation.
Location:
trunk/Forms
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormMain.lfm

    r136 r143  
    322322        Action = FormSourceCode.AGenerateNumber
    323323      end
     324      object MenuItem21: TMenuItem
     325        Action = FormSourceCode.AGenerateText
     326      end
    324327    end
    325328    object MenuItem9: TMenuItem
     
    386389  object ActionList1: TActionList
    387390    Images = Core.ImageListMain
    388     Left = 270
     391    Left = 272
    389392    Top = 240
    390393    object AProjectOpen: TAction
  • trunk/Forms/UFormMain.pas

    r136 r143  
    5454    MenuItem2: TMenuItem;
    5555    MenuItem20: TMenuItem;
     56    MenuItem21: TMenuItem;
    5657    MenuItem22: TMenuItem;
    5758    MenuItem24: TMenuItem;
  • trunk/Forms/UFormMemory.lfm

    r112 r143  
    11object FormMemory: TFormMemory
    22  Left = 565
    3   Height = 388
    4   Top = 182
    5   Width = 586
     3  Height = 418
     4  Top = 168
     5  Width = 1082
    66  Caption = 'Memory'
    7   ClientHeight = 388
    8   ClientWidth = 586
    9   DesignTimePPI = 144
    10   LCLVersion = '2.0.2.0'
     7  ClientHeight = 418
     8  ClientWidth = 1082
     9  DesignTimePPI = 150
     10  LCLVersion = '2.2.0.4'
    1111  object Label6: TLabel
    1212    Left = 6
    13     Height = 26
     13    Height = 27
    1414    Top = 6
    15     Width = 574
     15    Width = 1070
    1616    Align = alTop
    1717    BorderSpacing.Around = 6
    1818    Caption = 'Memory:'
    19     ParentColor = False
    2019    ParentFont = False
    2120  end
    2221  object ListViewMemory: TListView
    2322    Left = 6
    24     Height = 344
    25     Top = 38
    26     Width = 574
     23    Height = 373
     24    Top = 39
     25    Width = 1070
    2726    Align = alClient
    2827    BorderSpacing.Around = 6
     
    3029      item
    3130        Caption = 'Address'
    32         Width = 120
     31        Width = 125
    3332      end   
    3433      item
    3534        Caption = 'Data'
    36         Width = 495
     35        Width = 516
     36      end   
     37      item
     38        Caption = 'Text'
     39        Width = 414
    3740      end>
    38     Font.Height = -18
     41    Font.Height = -19
    3942    Font.Name = 'Courier New'
    4043    OwnerData = True
  • trunk/Forms/UFormMemory.lrj

    r112 r143  
    33{"hash":63203738,"name":"tformmemory.label6.caption","sourcebytes":[77,101,109,111,114,121,58],"value":"Memory:"},
    44{"hash":128683235,"name":"tformmemory.listviewmemory.columns[0].caption","sourcebytes":[65,100,100,114,101,115,115],"value":"Address"},
    5 {"hash":305313,"name":"tformmemory.listviewmemory.columns[1].caption","sourcebytes":[68,97,116,97],"value":"Data"}
     5{"hash":305313,"name":"tformmemory.listviewmemory.columns[1].caption","sourcebytes":[68,97,116,97],"value":"Data"},
     6{"hash":371956,"name":"tformmemory.listviewmemory.columns[2].caption","sourcebytes":[84,101,120,116],"value":"Text"}
    67]}
  • trunk/Forms/UFormMemory.pas

    r112 r143  
    5454  Row: string;
    5555  I: Integer;
     56  Text: string;
     57  Address: Integer;
    5658begin
    5759  if Core.CurrentTarget is TTargetInterpretter then
     
    6062    Item.Caption := IntToHex(Item.Index * RowSize, 8);
    6163    Row := '';
    62     for I := 0 to RowSize - 1 do
    63       if (Item.Index * RowSize + I) < (MemoryMaxUsedAddr + 1) then
    64         Row := Row + ' ' + IntToHex(Memory[Item.Index * RowSize + I], 2);
     64    Text := Default(string);
     65    SetLength(Text, RowSize);
     66    for I := 0 to RowSize - 1 do begin
     67      Address := Item.Index * RowSize + I;
     68      if Address < (MemoryMaxUsedAddr + 1) then begin
     69        Row := Row + ' ' + IntToHex(Memory[Address], 2);
     70        if Memory[Address] > Ord(' ') then Text[I + 1] := Chr(Memory[Address])
     71          else Text[I + 1] := ' ';
     72      end else Text[I + 1] := ' ';
     73    end;
    6574    Item.SubItems.Add(Row);
     75    Item.SubItems.Add(Text);
    6676  end;
    6777end;
  • trunk/Forms/UFormSourceCode.lfm

    r133 r143  
    11object FormSourceCode: TFormSourceCode
    22  Left = 459
    3   Height = 589
     3  Height = 614
    44  Top = 278
    5   Width = 672
     5  Width = 700
    66  Caption = 'Source code'
    7   ClientHeight = 589
    8   ClientWidth = 672
    9   DesignTimePPI = 144
     7  ClientHeight = 614
     8  ClientWidth = 700
     9  DesignTimePPI = 150
    1010  OnCreate = FormCreate
    1111  OnDestroy = FormDestroy
     
    1313  inline SynEditSource: TSynEdit
    1414    Left = 0
    15     Height = 589
     15    Height = 614
    1616    Top = 0
    17     Width = 672
     17    Width = 700
    1818    Align = alClient
    19     Font.Height = -16
     19    Font.Height = -17
    2020    Font.Name = 'Courier New'
    2121    Font.Pitch = fpFixed
     
    2929    OnKeyUp = MemoSourceKeyUp
    3030    OnMouseDown = MemoSourceMouseDown
    31     Gutter.Width = 80
     31    Gutter.Width = 83
    3232    Gutter.MouseActions = <>
    3333    RightGutter.Width = 0
     
    479479    inline SynLeftGutterPartList1: TSynGutterPartList
    480480      object SynGutterMarks1: TSynGutterMarks
    481         Width = 36
     481        Width = 38
    482482        MouseActions = <>
    483483      end
     
    506506      object SynGutterCodeFolding1: TSynGutterCodeFolding
    507507        AutoSize = False
    508         Width = 14
     508        Width = 15
    509509        MouseActions = <>
    510510        MarkupInfo.Background = clNone
     
    517517  object PopupMenuSource: TPopupMenu
    518518    Images = Core.ImageListMain
    519     Left = 154
    520     Top = 154
     519    Left = 160
     520    Top = 160
    521521    object MenuItem23: TMenuItem
    522522      Action = FormMain.ABreakpointToggle
    523     end
    524     object MenuItem26: TMenuItem
    525       Action = AFormatSource
    526     end
    527     object MenuItem21: TMenuItem
    528       Action = AGenerateNumber
    529523    end
    530524    object MenuItem29: TMenuItem
     
    567561      }
    568562    end
     563    object Separator1: TMenuItem
     564      Caption = '-'
     565    end
     566    object MenuItem26: TMenuItem
     567      Action = AFormatSource
     568    end
    569569    object MenuItem36: TMenuItem
    570570      Action = AShrinkSource
     571    end
     572    object MenuItem21: TMenuItem
     573      Action = AGenerateNumber
     574    end
     575    object MenuItem7: TMenuItem
     576      Action = AGenerateText
    571577    end
    572578    object MenuItem1: TMenuItem
     
    591597  object ActionList1: TActionList
    592598    Images = Core.ImageListMain
    593     Left = 152
    594     Top = 67
     599    Left = 158
     600    Top = 70
    595601    object AGenerateNumber: TAction
    596602      Caption = 'Generate number'
     
    641647      ShortCut = 16472
    642648    end
     649    object AGenerateText: TAction
     650      Caption = 'Generate text'
     651      ImageIndex = 29
     652      OnExecute = AGenerateTextExecute
     653    end
    643654  end
    644655  object SynJavaSyn1: TSynJavaSyn
    645656    DefaultFilter = 'Soubory Java (*.java)|*.java'
    646657    Enabled = False
    647     Left = 486
    648     Top = 316
     658    Left = 506
     659    Top = 329
    649660  end
    650661end
  • trunk/Forms/UFormSourceCode.lrj

    r115 r143  
    1515{"hash":195296268,"name":"tformsourcecode.aselectall.hint","sourcebytes":[83,101,108,101,99,116,32,97,108,108],"value":"Select all"},
    1616{"hash":19140,"name":"tformsourcecode.acuttoclipboard.caption","sourcebytes":[67,117,116],"value":"Cut"},
    17 {"hash":19140,"name":"tformsourcecode.acuttoclipboard.hint","sourcebytes":[67,117,116],"value":"Cut"}
     17{"hash":19140,"name":"tformsourcecode.acuttoclipboard.hint","sourcebytes":[67,117,116],"value":"Cut"},
     18{"hash":129197108,"name":"tformsourcecode.ageneratetext.caption","sourcebytes":[71,101,110,101,114,97,116,101,32,116,101,120,116],"value":"Generate text"}
    1819]}
  • trunk/Forms/UFormSourceCode.pas

    r131 r143  
    1515
    1616  TFormSourceCode = class(TForm)
     17    AGenerateText: TAction;
    1718    ACutToClipboard: TAction;
    1819    ASelectAll: TAction;
     
    3536    MenuItem5: TMenuItem;
    3637    MenuItem6: TMenuItem;
     38    MenuItem7: TMenuItem;
     39    Separator1: TMenuItem;
    3740    PopupMenuSource: TPopupMenu;
    3841    SynEditSource: TSynEdit;
     
    4346    procedure AFormatSourceExecute(Sender: TObject);
    4447    procedure AGenerateNumberExecute(Sender: TObject);
     48    procedure AGenerateTextExecute(Sender: TObject);
    4549    procedure APasteFromClipboardExecute(Sender: TObject);
    4650    procedure ASelectAllExecute(Sender: TObject);
     
    7276
    7377uses
    74   UCore, UFormMain;
     78  UCore, UFormMain, UBFCodeTools;
    7579
    7680resourcestring
    7781  SNumberGeneration = 'Number generation';
    7882  SEnterNumber = 'Enter number';
    79 
     83  STextGeneration = 'Text generation';
     84  SEnterText = 'Enter text';
    8085
    8186{ TFormSourceCode }
     
    8388procedure TFormSourceCode.AGenerateNumberExecute(Sender: TObject);
    8489var
     90  Number: Integer;
    8591  NumberText: string;
    86   Number: Integer;
    87   I: Integer;
    8892begin
    8993  NumberText := InputBox(SNumberGeneration, SEnterNumber, '1');
    9094  if TryStrToInt(NumberText, Number) then begin
    91     NumberText := '';
    92     for I := 0 to Number - 1 do
    93       NumberText := NumberText + '+';
    94     SynEditSource.SelText := NumberText;
     95    SynEditSource.SelText := GenerateNumber(Number);
    9596  end;
    9697end;
    9798
     99procedure TFormSourceCode.AGenerateTextExecute(Sender: TObject);
     100var
     101  Text: string;
     102begin
     103  Text := InputBox(STextGeneration, SEnterText, '');
     104  SynEditSource.SelText := GenerateText(Text);
     105end;
     106
    98107procedure TFormSourceCode.APasteFromClipboardExecute(Sender: TObject);
    99108begin
     
    107116
    108117procedure TFormSourceCode.AFormatSourceExecute(Sender: TObject);
    109 var
    110   Source: string;
    111   NewSource: string;
    112   Indent: Integer;
    113   I: Integer;
    114 const
    115   IndentText = '  ';
    116 begin
    117   Source := SynEditSource.Text;
    118   NewSource := '';
    119   Indent := 0;
    120   for I := 1 to Length(Source) do begin
    121     if Source[I] = '[' then begin
    122       NewSource := NewSource + LineEnding + DupeString(IndentText, Indent) + Source[I] + LineEnding ;
    123       Inc(Indent);
    124       NewSource := NewSource + DupeString(IndentText, Indent);
    125     end
    126     else if Source[I] = ']' then begin
    127       Dec(Indent);
    128       NewSource := NewSource + LineEnding + DupeString(IndentText, Indent) + Source[I] + LineEnding + DupeString(IndentText, Indent);
    129     end
    130     else if Ord(Source[I]) > $20 then
    131       NewSource := NewSource + Source[I];
    132   end;
    133   SynEditSource.Text := NewSource;
     118begin
     119  SynEditSource.Text := FormatCode(SynEditSource.Text);
    134120  MemoSourceChange(nil);
    135121end;
     
    151137
    152138procedure TFormSourceCode.AShrinkSourceExecute(Sender: TObject);
    153 var
    154   Source: string;
    155   Pos: Integer;
    156   I: Integer;
    157 begin
    158   Source := SynEditSource.Text;
    159   Pos := 1;
    160   for I := 1 to Length(Source) do begin
    161     if Source[I] > ' ' then begin
    162       Source[Pos] := Source[I];
    163       Inc(Pos);
    164     end;
    165   end;
    166   SetLength(Source, Pos - 1);
    167   SynEditSource.Text := Source;
     139begin
     140  SynEditSource.Text := ShrinkCode(SynEditSource.Text);
    168141  MemoSourceChange(nil);
    169142end;
Note: See TracChangeset for help on using the changeset viewer.