Changeset 6


Ignore:
Timestamp:
May 2, 2014, 2:12:56 AM (11 years ago)
Author:
chronos
Message:
  • Added: Search form for searching configuration tree.
  • Modified: Better menu category creation. Still not correct.
  • Added: Detect kernel version from Makefile.
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LinuxBuilder.lpi

    r5 r6  
    3333      </Item1>
    3434    </RequiredPackages>
    35     <Units Count="6">
     35    <Units Count="7">
    3636      <Unit0>
    3737        <Filename Value="LinuxBuilder.lpr"/>
     
    7676        <UnitName Value="UFormCompare"/>
    7777      </Unit5>
     78      <Unit6>
     79        <Filename Value="UFormSearch.pas"/>
     80        <IsPartOfProject Value="True"/>
     81        <ComponentName Value="FormSearch"/>
     82        <ResourceBaseClass Value="Form"/>
     83        <UnitName Value="UFormSearch"/>
     84      </Unit6>
    7885    </Units>
    7986  </ProjectOptions>
  • trunk/LinuxBuilder.lpr

    r5 r6  
    88  {$ENDIF}{$ENDIF}
    99  Interfaces, // this includes the LCL widgetset
    10   Forms, UFormMain, UKConfig, UFormList, UFormLog, UFormCompare
     10  Forms, UFormMain, UKConfig, UFormList, UFormLog, UFormCompare, UFormSearch
    1111  { you can add units after this };
    1212
     
    2020  Application.CreateForm(TFormLog, FormLog);
    2121  Application.CreateForm(TFormCompare, FormCompare);
     22  Application.CreateForm(TFormSearch, FormSearch);
    2223  Application.Run;
    2324end.
  • trunk/UFormMain.lfm

    r5 r6  
    2323    ReadOnly = True
    2424    RowSelect = True
     25    ShowRoot = False
    2526    TabOrder = 0
    2627    OnSelectionChanged = TreeView1SelectionChanged
    27     Options = [tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoRowSelect, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips, tvoThemedDraw]
     28    Options = [tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoRowSelect, tvoShowButtons, tvoShowLines, tvoToolTips, tvoThemedDraw]
    2829  end
    2930  object StatusBar1: TStatusBar
     
    6162      Action = AShowList
    6263    end
     64    object ToolButton3: TToolButton
     65      Left = 47
     66      Top = 2
     67      Action = ASearch
     68    end
     69    object ToolButton4: TToolButton
     70      Left = 70
     71      Top = 2
     72      Action = AShowLog
     73    end
    6374  end
    6475  object Memo1: TMemo
     
    8091      object MenuItem4: TMenuItem
    8192        Action = AOpenDir
     93        Bitmap.Data = {
     94          36040000424D3604000000000000360000002800000010000000100000000100
     95          2000000000000004000064000000640000000000000000000000000000000000
     96          0000000000000000000000000000000000000000000000000000000000000000
     97          0000000000000000000000000000000000000000000000000000000000000000
     98          0000000000000000000000000000000000000000000000000000000000000000
     99          0000000000000000000000000000000000000000000000000000000000FF0000
     100          00FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF0000
     101          00FF000000FF0000000000000000000000000000000000000000000000FF0000
     102          00FF008484FF008484FF008484FF008484FF008484FF008484FF008484FF0084
     103          84FF008484FF000000FF00000000000000000000000000000000000000FF00FF
     104          FFFF000000FF008484FF008484FF008484FF008484FF008484FF008484FF0084
     105          84FF008484FF008484FF000000FF000000000000000000000000000000FFFFFF
     106          FFFF00FFFFFF000000FF008484FF008484FF008484FF008484FF008484FF0084
     107          84FF008484FF008484FF008484FF000000FF0000000000000000000000FF00FF
     108          FFFFFFFFFFFF00FFFFFF000000FF008484FF008484FF008484FF008484FF0084
     109          84FF008484FF008484FF008484FF008484FF000000FF00000000000000FFFFFF
     110          FFFF00FFFFFFFFFFFFFF00FFFFFF000000FF000000FF000000FF000000FF0000
     111          00FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF00FF
     112          FFFFFFFFFFFF00FFFFFFFFFFFFFF00FFFFFFFFFFFFFF00FFFFFFFFFFFFFF00FF
     113          FFFF000000FF0000000000000000000000000000000000000000000000FFFFFF
     114          FFFF00FFFFFFFFFFFFFF00FFFFFFFFFFFFFF00FFFFFFFFFFFFFF00FFFFFFFFFF
     115          FFFF000000FF0000000000000000000000000000000000000000000000FF00FF
     116          FFFFFFFFFFFF00FFFFFF000000FF000000FF000000FF000000FF000000FF0000
     117          00FF000000FF0000000000000000000000000000000000000000000000000000
     118          00FF000000FF000000FF00000000000000000000000000000000000000000000
     119          00000000000000000000000000FF000000FF000000FF00000000000000000000
     120          0000000000000000000000000000000000000000000000000000000000000000
     121          0000000000000000000000000000000000FF000000FF00000000000000000000
     122          0000000000000000000000000000000000000000000000000000000000FF0000
     123          00000000000000000000000000FF00000000000000FF00000000000000000000
     124          0000000000000000000000000000000000000000000000000000000000000000
     125          00FF000000FF000000FF00000000000000000000000000000000000000000000
     126          0000000000000000000000000000000000000000000000000000000000000000
     127          0000000000000000000000000000000000000000000000000000
     128        }
    82129      end
    83130      object MenuItem7: TMenuItem
     
    89136      object MenuItem3: TMenuItem
    90137        Action = AViemSystem
     138        Bitmap.Data = {
     139          36040000424D3604000000000000360000002800000010000000100000000100
     140          2000000000000004000064000000640000000000000000000000FFFFFF00FFFF
     141          FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
     142          FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
     143          FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
     144          FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
     145          FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
     146          FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
     147          FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
     148          FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00030303000404
     149          0400040404000404040A04040435040404650404047B04040488040404880404
     150          047B04040465040404350404040A040404000404040003030300030303000404
     151          0401040404390C0C0C80545454ACAAAAAAD88C8C8CF15E5E5EFE5E5E5EFE8C8C
     152          8CF1AAAAAAD8545454AC0C0C0C80040404390404040103030300030303070404
     153          045A3A3A3AA5C6C6C6E6E7E7E7FFA2A2A2FF645D5DFF9E8484FF9E8484FF645D
     154          5DFFA2A2A2FFE7E7E7FFC6C6C6E63A3A3AA50404045A03030307030303414848
     155          48B1E2E2E2F7EAEAEAFFEAEAEAFF646464FF816F6FFF7A6767FF7A6767FF816F
     156          6FFF646464FFEAEAEAFFEAEAEAFFE2E2E2F7484848B103030341030303A07E7E
     157          7ED0F0F0F0FFF0F0F0FFF0F0F0FF434343FFBAB2B2FF352E2EFF352E2EFF6D5F
     158          5FFF434343FFF0F0F0FFF0F0F0FFF0F0F0FF7E7E7ED0030303A0030303484646
     159          46BEE9E9E9F9F6F6F6FFF6F6F6FFBDBDBDFFFFFFFFFF9E9B9BFF413C3CFF4C46
     160          46FF5C5C5CFFF6F6F6FFF6F6F6FFE9E9E9F9464646BE03030348010101080101
     161          0171353535C6CACACAF0FBFBFBFFA6A6A6FF9B9B9BFF383737FF383737FF3838
     162          38FFA6A6A6FFFBFBFBFFCACACAF0353535C60101017101010108010101000101
     163          01010000004F070707B44D4D4DD8A9A9A9EE7E7E7EF9424242FF424242FF7E7E
     164          7EF9A9A9A9EE4D4D4DD8070707B40000004F0101010101010100010101000101
     165          0100000000000000000E0000004E00000094000000B6000000C8000000C80000
     166          00B6000000940000004E0000000E000000000101010001010100FFFFFF00FFFF
     167          FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
     168          FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
     169          FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
     170          FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
     171          FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
     172          FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00
     173        }
    91174      end
    92175      object MenuItem5: TMenuItem
    93176        Action = AShowList
     177        Bitmap.Data = {
     178          36040000424D3604000000000000360000002800000010000000100000000100
     179          2000000000000004000064000000640000000000000000000000986B37FF976A
     180          36FF966935FF966734FF956633FF946532FF946531FF936430FF92622FFF9261
     181          2EFF91602DFF90602CFF905F2BFF8F5D2AFF8E5C29FF8D5B28FF996C38FFF8F7
     182          F6FFF8F7F5FFF7F6F5FFF6F6F4FFF6F5F3FFF5F5F3FFF5F4F2FFF4F3F1FFF4F3
     183          F1FFF3F2F0FFF3F2EFFFF2F1EFFFF2F0EEFFF1F0EDFF8E5D29FF996D3AFFF9F8
     184          F7FF959594FF878787FF9B9A9AFFF7F6F4FFF6F5F3FFF6F5F3FFF5F4F2FFF4F3
     185          F1FFF4F3F1FFF3F2F0FFF3F2EFFFF2F1EFFFF2F1EEFF8F5E2AFF9A6E3BFFF9F9
     186          F8FF7C7C7CFFC4C4C4FF878787FFF7F6F5FF7A7A7AFF787878FF747474FF7171
     187          70FF6D6D6CFF696968FF656565FF616161FFF2F1EFFF905F2BFF9B6F3CFFFAF9
     188          F8FFBEBEBDFF929292FFBCBCBBFFF8F7F6FFF7F7F5FFF7F6F4FFF6F5F4FFF6F5
     189          F3FFF5F4F2FFF5F4F2FFF4F3F1FFF4F2F0FFF3F2F0FF91602DFF9C703DFFFAFA
     190          F9FFFAF9F9FFF9F9F8FFF9F8F7FFF8F8F7FFF8F7F6FFF7F7F5FFF7F6F5FFF6F5
     191          F4FFF6F5F3FFF5F4F3FFF5F4F2FFF4F3F1FFF4F3F0FF92612EFF9D723EFFFBFB
     192          FAFF9F9F9EFF7F7F7FFFAEAEADFFF9F8F7FFF8F8F7FFF8F7F6FFF7F7F5FFF7F6
     193          F5FFF6F6F4FFF6F5F3FFF5F4F3FFF5F4F2FFF4F3F1FF92622FFF9D7340FFFCFB
     194          FBFF818181FFC4C4C4FF8F8F8FFFFAF9F8FF7B7B7AFF797979FF757574FF7271
     195          71FF6D6D6DFF696969FF666665FF626261FFF5F4F2FF936430FF9E7441FFFCFC
     196          FCFFB5B5B5FF848484FFBEBDBDFFFAFAF9FFFAF9F8FFF9F9F7FFF9F8F7FFF8F8
     197          F6FFF8F7F5FFF7F6F5FFF7F6F4FFF6F5F3FFF6F5F3FF946531FF9F7542FFFDFD
     198          FCFFFCFCFCFFFCFCFBFFFBFBFAFFFBFAFAFFFAFAF9FFFAF9F8FFF9F9F8FFF9F8
     199          F7FFF8F8F6FFF8F7F6FFF7F6F5FFF7F6F4FFF6F5F4FF956633FFA07643FFFEFD
     200          FDFF8C8C8CFF525252FFA4A4A4FFFBFBFAFFFBFBFAFFFAFAF9FFFAF9F8FFF9F9
     201          F8FFF9F8F7FFF8F8F6FFF8F7F6FFF7F7F5FFF7F6F4FF966734FFA17844FFFEFE
     202          FEFF5F5F5FFF949494FF535353FFFCFCFBFF7B7B7BFF797979FF757575FF7272
     203          72FF6E6E6EFF6A6A69FF666666FF626262FFF7F7F5FF966935FFA17946FFFFFF
     204          FFFF878787FF5D5D5DFFA0A0A0FFFDFCFCFFFCFCFBFFFCFBFBFFFBFBFAFFFBFA
     205          F9FFFAFAF9FFFAF9F8FFF9F8F7FFF8F8F7FFF8F7F6FF976A36FFA27A47FFFFFF
     206          FFFFFFFFFFFFFEFEFEFFFEFEFEFFFDFDFDFFFDFDFCFFFCFCFBFFFCFBFBFFFBFB
     207          FAFFFBFAF9FFFAFAF9FFFAF9F8FFF9F9F7FFF9F8F7FF986B37FFA37B48FFBEA2
     208          7FFFBEA17EFFBDA17DFFBDA07CFFBD9F7CFFBC9F7BFFBB9E7AFFBB9D7AFFBB9D
     209          79FFBA9C78FFB99B78FFB99A77FFB89A76FFB89975FF996C39FFA37B48FFA37B
     210          48FFA27A47FFA27946FFA17845FFA07744FFA07643FF9F7542FF9E7441FF9E73
     211          40FF9D723FFF9C713EFF9C703DFF9B6F3CFF9A6E3BFF9A6D3AFF
     212        }
    94213      end
    95214      object MenuItem6: TMenuItem
    96215        Action = AShowLog
     216        Bitmap.Data = {
     217          36040000424D3604000000000000360000002800000010000000100000000100
     218          200000000000000400006400000064000000000000000000000000000000858A
     219          88A3858A88FF858A88FF858A88FF858A88FF858A88FF858A88FF858A88FF858A
     220          88FF858A88FF858A88FF858A88FF858A88A3000000000000000000000000858A
     221          88FFEEEEEEFFB2B2B2FFB2B2B2FFB2B2B2FFB2B2B2FFB2B2B2FFB2B2B2FFB2B2
     222          B2FFB1B1B1FFB2B2B2FFB2B2B2FF858A88FF000000000000000000000000858A
     223          88FFFFFFFFFFECECECFFEBEBEBFFEAEAEAFFEAEAEAFFE9E9E9FFEBEBEBFFEAEA
     224          EAFFEBEBEBFFECECECFFB2B2B2FF858A88FF000000000000000000000000858A
     225          88FFFFFFFFFFDBDBDBFFCBCBCBFFC4C4C4FF000000FF02598FFF636363FF8C8C
     226          8CFFCACACAFFDADADAFFB2B2B2FF858A88FF000000020000000000000000858A
     227          88FFFFFFFFFFECECECFFECECECFFE9E9E9FF02598FFF26424CFF36576BFF0259
     228          8FFF9D9D9DFFD6D6D6FFAEAEAEFF858A88FF000000000000000000000000858A
     229          88FFFFFFFFFFDBDBDBFFCCCCCCFFCBCBCBFF757575FF395B70FF8AABC2FF5585
     230          A3FF02598FFF8F8F8FFF868686FF858A88FF000000010000000000000000858A
     231          88FFFFFFFFFFECECECFFECECECFFECECECFFEBEBEBFF02598FFFC4E5EDFF649F
     232          C8FF5787A4FF02598FFF717171FF858A88FF000000000000000100000000858A
     233          88FFFFFFFFFFDBDBDBFFCCCCCCFFCCCCCCFFCCCCCCFFB7B7B7FF02598FFFC5E6
     234          EDFF68A6CEFF5784A0FF02598FFF858A88FF000000000000000100000000858A
     235          88FFFFFFFFFFECECECFFECECECFFECECECFFECECECFFECECECFFD3D3D3FF0259
     236          8FFFC6EAEEFF69AACFFF5683A0FF02598FFF02598F330000000000000000858A
     237          88FFFFFFFFFFDBDBDBFFCCCCCCFFCCCCCCFFCCCCCCFFCCCCCCFFCCCCCCFFB7B7
     238          B7FF02598FFFC7EBEFFF6AACD2FF5787A4FF02598FFF02598F3300000000858A
     239          88FFFFFFFFFFECECECFFECECECFFECECECFFECECECFFECECECFFECECECFFECEC
     240          ECFFD3D3D3FF02598FFFC7EBEFFF6AACD2FF5583A1FC02598FFF00000000858A
     241          88FFEBEBEBFF00A0C4FFBCBCBCFF00A0C4FFB8B8B8FF00A0C4FFB8B8B8FF00A0
     242          C4FFB8B8B8FF00A0C4FF02598FFFC6EAEEFF71ADCFFF02598FFF00000000858A
     243          88FF00A0C4FF3DB1EBFF00A0C4FF3DB1EBFF00A0C4FF3DB1EBFF00A0C4FF3DB1
     244          EBFF00A0C4FF3DB1EBFF00A0C4FF02598FFF02598FFF02598F5C00000000858A
     245          886600A0C4FFC6E8F9FF00A0C4FFC6E8F9FF00A0C4FFC6E8F9FF00A0C4FFC6E8
     246          F9FF00A0C4FFC6E8F9FF00A0C4FF000000000000000000000000000000000000
     247          000000A0C44400A0C4FF00A0C44400A0C4FF00A0C44400A0C4FF00A0C44400A0
     248          C4FF00A0C44400A0C4FF00A0C444000000000000000000000000000000000000
     249          0000000000000000000000000000000000000000000000000000000000000000
     250          0000000000000000000000000000000000000000000000000000
     251        }
     252      end
     253      object MenuItem8: TMenuItem
     254        Action = ASearch
    97255      end
    98256    end
     
    100258  object ActionList1: TActionList
    101259    Images = ImageList1
    102     left = 239
     260    left = 240
    103261    top = 264
    104262    object AOpenDir: TAction
     
    125283      Caption = 'Compare with directory'
    126284      OnExecute = ACompareExecute
     285    end
     286    object ASearch: TAction
     287      Caption = 'Search'
     288      OnExecute = ASearchExecute
     289      ShortCut = 16454
    127290    end
    128291  end
  • trunk/UFormMain.pas

    r5 r6  
    1515  TFormMain = class(TForm)
    1616    ACompare: TAction;
     17    ASearch: TAction;
    1718    AShowList: TAction;
    1819    AShowLog: TAction;
     
    3031    MenuItem6: TMenuItem;
    3132    MenuItem7: TMenuItem;
     33    MenuItem8: TMenuItem;
    3234    StatusBar1: TStatusBar;
    3335    ToolBar1: TToolBar;
    3436    ToolButton1: TToolButton;
    3537    ToolButton2: TToolButton;
     38    ToolButton3: TToolButton;
     39    ToolButton4: TToolButton;
    3640    TreeView1: TTreeView;
    3741    procedure ACompareExecute(Sender: TObject);
    3842    procedure AOpenDirExecute(Sender: TObject);
     43    procedure ASearchExecute(Sender: TObject);
    3944    procedure AShowListExecute(Sender: TObject);
    4045    procedure AShowLogExecute(Sender: TObject);
     
    4954    Config: TConfigMenu;
    5055    procedure Reload;
     56    procedure FocusTreeNode(Node: TMenuNode);
    5157  end;
    5258
     
    5763
    5864uses
    59   UFormList, UFormLog, UFormCompare;
     65  UFormList, UFormLog, UFormCompare, UFormSearch;
    6066
    6167{$R *.lfm}
     
    96102end;
    97103
     104procedure TFormMain.FocusTreeNode(Node: TMenuNode);
     105var
     106  TreeNode: TTreeNode;
     107begin
     108  TreeNode := TreeView1.Items.FindNodeWithData(Node);
     109  if Assigned(TreeNode) then begin
     110    TreeNode.Selected := True;
     111    TreeNode.ExpandParents;
     112  end;
     113end;
     114
    98115procedure TFormMain.AOpenDirExecute(Sender: TObject);
    99116var
     
    104121    Reload;
    105122  end;
     123end;
     124
     125procedure TFormMain.ASearchExecute(Sender: TObject);
     126begin
     127  FormSearch.Show;
    106128end;
    107129
  • trunk/UKConfig.pas

    r5 r6  
    3131    Items: TObjectList; // TList<TMenuNode>
    3232    Parent: TMenuNode;
     33    NewParent: TMenuNode;
    3334    DefaultValue: string;
    3435    ValueType: TValueType;
     
    3738    constructor Create; virtual;
    3839    destructor Destroy; override;
     40    function HaveUpperNode(Node: TMenuNode): Boolean;
    3941    function GetName: string; virtual;
    40     function GetabsoluteName: string; virtual;
     42    function GetAbsoluteName: string; virtual;
    4143    procedure LoadTreeNode(Node: TTreeNode; Options: TLoadTreeOptions = []); virtual;
    4244    procedure LoadStats(List: TStrings); virtual;
    4345    procedure GetNodes(List: TStrings); virtual;
     46    procedure Search(Text: string; List: TObjectList); virtual;
    4447    procedure SaveToList(List: TStrings); virtual;
    4548    procedure PrepareMoveList(Lookup: TStringList; var List: TObjectMoves); virtual;
     
    5659  private
    5760    CurrentMenu: TMenuNode;
     61    ConditionStack: TStringList;
    5862    Arch: string;
    5963    FOnLog: TOnLogEvent;
     64    function GetTopCondition: string;
    6065    procedure Log(Text: string);
    6166    function IsWhiteSpace(Character: Char): Boolean;
    6267    function GetNextToken(var Text: string): string;
    6368    procedure ParseFile(FileName: string);
     69    procedure ParseConfig;
     70    procedure ParseMakeFile;
    6471  public
    6572    TopNode: TMenuNode;
    6673    BaseDir: string;
     74    Version: string;
    6775    procedure PrepareMoveList(var List: TObjectMoves);
    6876    procedure CompareStringLists(List1, List2: TStringList; Missing1,
     
    7078    procedure LoadFromDir(Dir: string; Arch: string);
    7179    property OnLog: TOnLogEvent read FOnLog write FOnLog;
     80    constructor Create;
     81    destructor Destroy; override;
    7282  end;
    7383
     
    96106end;
    97107
     108function TMenuNode.HaveUpperNode(Node: TMenuNode): Boolean;
     109begin
     110  Result := False;
     111  if NewParent = Node then Result := True
     112    else if Assigned(NewParent) then Result := NewParent.HaveUpperNode(Node);
     113end;
     114
    98115function TMenuNode.GetName: string;
    99116begin
     
    102119end;
    103120
    104 function TMenuNode.GetabsoluteName: string;
    105 begin
    106   if Assigned(Parent) then Result := Parent.GetabsoluteName + ' - ';
    107   Result := Result + GetName;
     121function TMenuNode.GetAbsoluteName: string;
     122begin
     123  if Assigned(Parent) then Result := Parent.GetAbsoluteName + ' - ';
     124  if Assigned(Parent) then Result := Result + GetName;
    108125end;
    109126
     
    119136      NewNode.Data := TMenuNode(Self.Items[I]);
    120137      LoadTreeNode(NewNode, Options);
    121     end;
     138    end else LoadTreeNode(Node, Options);
    122139  end;
    123140end;
     
    149166end;
    150167
     168procedure TMenuNode.Search(Text: string; List: TObjectList);
     169var
     170  I: Integer;
     171begin
     172  if (Pos(Text, ID) > 0) or (Pos(Text, Name) > 0) then List.Add(Self);
     173  for I := 0 to Items.Count - 1 do
     174    TMenuNode(Items[I]).Search(Text, List);
     175end;
     176
    151177procedure TMenuNode.SaveToList(List: TStrings);
    152178var
     
    167193  Index: Integer;
    168194begin
     195  if ID = 'KVM_INTEL' then
     196    Name := Name + '$';
     197  NewParent := Parent;
     198  if Condition <> '' then begin
     199    Index := Lookup.IndexOf(Condition);
     200    if Index <> -1 then Node := TMenuNode(Lookup.Objects[Index])
     201      else Node := nil;
     202    if Assigned(Node) and (NewParent <> Node) then begin
     203      NewParent := Node;
     204    end;
     205  end;
    169206  if Depends.Count > 0 then begin
    170207    Index := Lookup.IndexOf(Depends[0]);
    171208    if Index <> -1 then Node := TMenuNode(Lookup.Objects[Index])
    172209      else Node := nil;
    173     if Assigned(Node) and (Parent <> Node) then begin
    174       NewMove.Source := Self;
    175       NewMove.NewParent := Node;
    176       SetLength(List, Length(List) + 1);
    177       List[Length(List) - 1] := NewMove;
     210    if Assigned(Node) and (NewParent <> Node) and (Node.HaveUpperNode(NewParent)) then begin
     211      NewParent := Node;
    178212    end;
    179   end else
    180   if Condition <> '' then begin
    181     Index := Lookup.IndexOf(Condition);
    182     if Index <> -1 then Node := TMenuNode(Lookup.Objects[Index])
    183       else Node := nil;
    184     if Assigned(Node) and (Parent <> Node) then begin
    185       NewMove.Source := Self;
    186       NewMove.NewParent := Node;
    187       SetLength(List, Length(List) + 1);
    188       List[Length(List) - 1] := NewMove;
    189     end;
    190   end;
     213  end;
     214  if NewParent <> Parent then begin
     215    NewMove.Source := Self;
     216    NewMove.NewParent := NewParent;
     217    SetLength(List, Length(List) + 1);
     218    List[Length(List) - 1] := NewMove;
     219  end;
     220
    191221  I := 0;
    192222  while I < Items.Count do
     
    231261
    232262{ TConfigMenu }
     263
     264function TConfigMenu.GetTopCondition: string;
     265begin
     266  if ConditionStack.Count > 0 then
     267  Result := ConditionStack[ConditionStack.Count - 1]
     268  else Result := '';
     269end;
    233270
    234271procedure TConfigMenu.Log(Text: string);
     
    285322  NewMenu: TMenuNode;
    286323  MergedLines: string;
    287   Condition: string;
    288324  HelpIndent: Integer;
    289325  LineIndent: Integer;
     
    302338    NewItem := nil;
    303339    MergedLines := '';
    304     Condition := '';
    305340    HelpIndent := 0;
    306341    for I := 0 to Content.Count - 1 do begin
     
    394429        if Parameter = 'on' then begin
    395430          Parameter := GetNextToken(Line);
     431          if Copy(Parameter, 1, 1) = '!' then Delete(Parameter, 1, 1);
    396432          if not Assigned(NewItem) then raise Exception.Create('Item not defined. ' + GetLog);
    397433          NewItem.Depends.Add(Parameter);
     
    413449      if (Command = 'config') or (Command = 'menuconfig') then begin
    414450        Parameter := GetNextToken(Line);
    415           State := stConfig;
    416           NewItem := TMenuNode.Create;
    417           NewItem.Parent := CurrentMenu;
    418           NewItem.ID := Parameter;
    419           NewItem.Condition := Condition;
    420           CurrentMenu.Items.Add(NewItem);
    421         end else
    422         if (Command = 'comment')  then begin
    423           Parameter := GetNextToken(Line);
    424           NewItem := TMenuNode.Create;
    425           NewItem.Parent := CurrentMenu;
    426           NewItem.ID := Parameter;
    427           NewItem.Condition := Condition;
    428           NewItem.ValueType := vtComment;
    429           CurrentMenu.Items.Add(NewItem);
    430         end else
    431         if Command = 'source' then begin
    432           Parameter := GetNextToken(Line);
    433           if Pos('$SRCARCH', Parameter) > 0 then
    434             Parameter := StringReplace(Parameter, '$SRCARCH', Arch, [rfReplaceAll]);
    435           Parameter := BaseDir + DirectorySeparator + Parameter;
    436           if FileExistsUTF8(Parameter) then
    437             ParseFile(Parameter)
    438             else raise Exception.Create('Source file "' + Parameter + '" not found. ' + GetLog);
    439         end else
    440         if Command = 'choice' then begin
    441           Parameter := GetNextToken(Line);
    442           NewMenu := TMenuNode.Create;
    443           NewMenu.ValueType := vtChoice;
    444           NewMenu.Name := Parameter;
    445           NewMenu.Parent := CurrentMenu;
    446           NewItem := NewMenu;
    447           CurrentMenu.Items.Add(NewMenu);
    448           CurrentMenu := NewMenu;
    449         end else
    450         if command = 'endchoice' then begin
    451           if Assigned(CurrentMenu.Parent) then
    452             CurrentMenu := CurrentMenu.Parent
    453             else raise Exception.Create('Can''t change menu level up. ' + GetLog);
    454         end else
    455         if Command = 'mainmenu' then begin
    456           Parameter := GetNextToken(Line);
    457           TopNode.Name := Parameter;
    458         end else
    459         if Command = 'menu' then begin
    460           Parameter := GetNextToken(Line);
    461           Log('MENU ' + Parameter + ' IN ' + CurrentMenu.GetAbsoluteName);
    462           NewMenu := TMenuNode.Create;
    463           NewMenu.Name := Parameter;
    464           NewMenu.Parent := CurrentMenu;
    465           NewMenu.Condition := Condition;
    466           Condition := '';
    467           NewItem := NewMenu;
    468           CurrentMenu.Items.Add(NewMenu);
    469           CurrentMenu := NewMenu;
    470         end else
    471         if command = 'endmenu' then begin
    472           Log('ENDMENU ' + CurrentMenu.GetAbsoluteName);
    473           if Assigned(CurrentMenu.Parent) then begin
    474             Condition := CurrentMenu.Condition;
    475             CurrentMenu := CurrentMenu.Parent;
    476           end else raise Exception.Create('Can''t change menu level up. ' + GetLog);
    477         end else
    478         if Command = 'if' then begin
    479           Condition := GetNextToken(Line);
    480         end else
    481         if Command = 'visible' then begin
    482           //VisibleCondition := GetNextToken(Line);
    483         end else
    484         if command = 'endif' then begin
    485           Condition := '';
    486         end else
    487           raise Exception.Create('Unknown command "' + Command + '". ' + GetLog);
     451        State := stConfig;
     452        NewItem := TMenuNode.Create;
     453        NewItem.Parent := CurrentMenu;
     454        NewItem.ID := Parameter;
     455        NewItem.Condition := GetTopCondition;
     456        CurrentMenu.Items.Add(NewItem);
     457      end else
     458      if (Command = 'comment')  then begin
     459        Parameter := GetNextToken(Line);
     460        NewItem := TMenuNode.Create;
     461        NewItem.Parent := CurrentMenu;
     462        NewItem.Name := Parameter;
     463        NewItem.Condition := GetTopCondition;
     464        NewItem.ValueType := vtComment;
     465        CurrentMenu.Items.Add(NewItem);
     466      end else
     467      if Command = 'source' then begin
     468        Parameter := GetNextToken(Line);
     469        if Pos('$SRCARCH', Parameter) > 0 then
     470          Parameter := StringReplace(Parameter, '$SRCARCH', Arch, [rfReplaceAll]);
     471        Parameter := BaseDir + DirectorySeparator + Parameter;
     472        if FileExistsUTF8(Parameter) then
     473          ParseFile(Parameter)
     474          else raise Exception.Create('Source file "' + Parameter + '" not found. ' + GetLog);
     475      end else
     476      if Command = 'choice' then begin
     477        Parameter := GetNextToken(Line);
     478        NewMenu := TMenuNode.Create;
     479        NewMenu.ValueType := vtChoice;
     480        NewMenu.Name := Parameter;
     481        NewMenu.Parent := CurrentMenu;
     482        NewMenu.Condition := GetTopCondition;
     483        ConditionStack.Add('');
     484        NewItem := NewMenu;
     485        CurrentMenu.Items.Add(NewMenu);
     486        CurrentMenu := NewMenu;
     487      end else
     488      if command = 'endchoice' then begin
     489        if Assigned(CurrentMenu.Parent) then begin
     490          ConditionStack.Delete(ConditionStack.Count - 1);
     491          CurrentMenu := CurrentMenu.Parent;
     492        end else raise Exception.Create('Can''t change menu level up. ' + GetLog);
     493      end else
     494      if Command = 'mainmenu' then begin
     495        Parameter := GetNextToken(Line);
     496        Parameter := StringReplace(Parameter, '$ARCH', Arch, [rfReplaceAll]);
     497        Parameter := StringReplace(Parameter, '$KERNELVERSION', Version, [rfReplaceAll]);
     498        TopNode.Name := Parameter;
     499      end else
     500      if Command = 'menu' then begin
     501        Parameter := GetNextToken(Line);
     502        Log('MENU ' + Parameter + ' IN ' + CurrentMenu.GetAbsoluteName);
     503        NewMenu := TMenuNode.Create;
     504        NewMenu.Name := Parameter;
     505        NewMenu.Parent := CurrentMenu;
     506        NewMenu.Condition := GetTopCondition;
     507        ConditionStack.Add('');
     508        NewItem := NewMenu;
     509        CurrentMenu.Items.Add(NewMenu);
     510        CurrentMenu := NewMenu;
     511      end else
     512      if command = 'endmenu' then begin
     513        Log('ENDMENU ' + CurrentMenu.GetAbsoluteName);
     514        if Assigned(CurrentMenu.Parent) then begin
     515          ConditionStack.Delete(ConditionStack.Count - 1);
     516          CurrentMenu := CurrentMenu.Parent;
     517        end else raise Exception.Create('Can''t change menu level up. ' + GetLog);
     518      end else
     519      if Command = 'if' then begin
     520        ConditionStack.Add(GetNextToken(Line));
     521      end else
     522      if Command = 'visible' then begin
     523        //VisibleCondition := GetNextToken(Line);
     524      end else
     525      if command = 'endif' then begin
     526        ConditionStack.Delete(ConditionStack.Count - 1);
     527      end else
     528        raise Exception.Create('Unknown command "' + Command + '". ' + GetLog);
     529    end;
     530  finally
     531    Content.Free;
     532  end;
     533end;
     534
     535procedure TConfigMenu.ParseConfig;
     536begin
     537  ConditionStack.Clear;
     538  TopNode.Free;
     539  TopNode := TMenuNode.Create;
     540  TopNode.Name := 'Root';
     541  CurrentMenu := TopNode;
     542  ParseFile(BaseDir + DirectorySeparator + 'Kconfig');
     543end;
     544
     545procedure TConfigMenu.ParseMakeFile;
     546var
     547  Content: TStringList;
     548  I: Integer;
     549  Line: string;
     550  Token: string;
     551begin
     552  try
     553    Content := TStringList.Create;
     554    Content.LoadFromFile(BaseDir + DirectorySeparator + 'Makefile');
     555    for I := 0 to Content.Count - 1 do begin
     556      Line := Trim(Content[I]);
     557      Token := GetNextToken(Line);
     558      if Token = 'VERSION' then begin
     559        Line := Trim(Line);
     560        Token := GetNextToken(Line);
     561        if Token = '=' then
     562          Version := Trim(Line);
     563      end else
     564      if Token = 'PATCHLEVEL' then begin
     565        Line := Trim(Line);
     566        Token := GetNextToken(Line);
     567        if Token = '=' then
     568          Version := Version + '.' + Trim(Line);
     569      end else
     570      if Token = 'SUBLEVEL' then begin
     571        Line := Trim(Line);
     572        Token := GetNextToken(Line);
     573        if Token = '=' then
     574          Version := Version + '.' + Trim(Line);
     575      end;
    488576    end;
    489577  finally
     
    548636  Self.Arch := Arch;
    549637  BaseDir := Dir;
    550   TopNode.Free;
    551   TopNode := TMenuNode.Create;
    552   TopNode.Name := 'Root';
    553   CurrentMenu := TopNode;
    554   ParseFile(BaseDir + DirectorySeparator + 'Kconfig');
    555 
     638  ParseMakeFile;
     639  ParseConfig;
     640
     641  SetLength(Moves, 0);
    556642  PrepareMoveList(Moves);
    557643  for I := 0 to Length(Moves) - 1 do
     
    565651end;
    566652
     653constructor TConfigMenu.Create;
     654begin
     655  ConditionStack := TStringList.Create;
     656end;
     657
     658destructor TConfigMenu.Destroy;
     659begin
     660  ConditionStack.Free;
     661end;
     662
    567663end.
    568664
Note: See TracChangeset for help on using the changeset viewer.