Что-то типа TStrHolder - но только именно их массив. Важен именно визуальный редактор сохраненных текстов в режиме дизайнера.
И доступ к сохранённым текстам желателен по ключу.
Самому лень писать - может что-то уже готовое есть?
Базы не предлагать
![Smile :-)](./images/smilies/icon_smile.gif)
Модератор: Модераторы
Alex2013 писал(а):Может я не вник в вопрос... Но извиняюсь , чем SynEdit не катит ?Там вроде все что нужно есть ...
Сворачиваемые блоки с крутой визуализацией есть , поиск есть, "скрытая древовидность " тоже есть и еще много чего что сразу и не вспомню ...
alexs писал(а):Мне нужен компонент для хранения массива текстов, не строк. С обязательным удобным заполнением этого массива в дизайнере.
unit TextSnippets;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils;
type
TSnippetCollection = class;
TSnippet = class;
TTextSnippets = class(TComponent)
private
FSnippets: TSnippetCollection;
procedure SetSnippets(aSnippets: TSnippetCollection);
public
constructor Create(aOwner: TComponent); override;
destructor Destroy; override;
function IndexOf(const aTitle: string): Integer;
published
property Items: TSnippetCollection read FSnippets write SetSnippets;
end;
TSnippetCollection = class(TCollection)
private
procedure SetItem(aIndex: Integer; aValue: TSnippet);
function GetItem(aIndex: Integer): TSnippet;
public
constructor Create;
property Items[aIndex: Integer]: TSnippet read GetItem write SetItem; default;
end;
TSnippet = class(TCollectionItem)
private
FList: TStrings;
FTitle: string;
procedure SetLines(aValue: TStrings);
protected
function GetDisplayName: string; override;
public
constructor Create(aCollection: TCollection); override;
destructor Destroy; override;
procedure Assign(aSource: TPersistent); override;
published
property Title: string read FTitle write FTitle;
property Lines: TStrings read FList write SetLines;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Misc', [TTextSnippets]);
end;
{ TTextSnippets }
procedure TTextSnippets.SetSnippets(aSnippets: TSnippetCollection);
begin
FSnippets.Assign(aSnippets);
end;
constructor TTextSnippets.Create(aOwner: TComponent);
begin
inherited Create(aOwner);
FSnippets := TSnippetCollection.Create;
end;
destructor TTextSnippets.Destroy;
begin
FSnippets.Free;
inherited;
end;
function TTextSnippets.IndexOf(const aTitle: string): Integer;
var
I: Integer;
begin
for I := 0 to Pred(FSnippets.Count) do
if CompareText(aTitle, FSnippets.Items[I].Title) = 0 then
exit(I);
Result := -1;
end;
{ TSnippetCollection }
procedure TSnippetCollection.SetItem(aIndex: Integer; aValue: TSnippet);
begin
inherited Items[aIndex] := aValue;
end;
function TSnippetCollection.GetItem(aIndex: Integer): TSnippet;
begin
Result := TSnippet(inherited Items[aIndex]);
end;
constructor TSnippetCollection.Create;
begin
inherited Create(TSnippet);
end;
{ TSnippet }
procedure TSnippet.SetLines(aValue: TStrings);
begin
if FList = aValue then
exit;
FList.Assign(aValue);
end;
function TSnippet.GetDisplayName: string;
begin
Result := FTitle;
end;
constructor TSnippet.Create(aCollection: TCollection);
begin
inherited Create(aCollection);
FList := TStringList.Create;
FTitle := 'Untitled';
end;
destructor TSnippet.Destroy;
begin
FList.Free;
inherited;
end;
procedure TSnippet.Assign(aSource: TPersistent);
begin
if aSource is TSnippet then
begin
FList.Assign(TSnippet(aSource).FList);
Title := TSnippet(aSource).Title;
end
else
AssignTo(aSource);
end;
end.
Вернуться в Сторонние средства
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 4