📄 rvervdata.pas
字号:
end;
{------------------------------------------------------------------------------}
function TRVEditRVData.GetUndoList: TRVUndoList;
begin
case UndoDest of
udUndo:
begin
if UndoList.Limit<>0 then
Result := UndoList
else
Result := nil;
end;
udRedo:
Result := RedoList;
else
Result := nil;
end;
end;
{------------------------------------------------------------------------------}
procedure TRVEditRVData.BeginRedoSequence(UndoType: TRVUndoType; const Caption: String);
begin
if RedoList.BeginItem(UndoType, Caption, GetCurItemNo, GetOffsetInCurItem) then
UndoDest := udRedo
else
UndoDest := udNone;
end;
{------------------------------------------------------------------------------}
procedure TRVEditRVData.BeginUndoSequence(UndoType: TRVUndoType; AllowFinalize: Boolean);
begin
if not (rvstFinalizingUndo in State) and AllowFinalize then begin
State := State + [rvstFinalizingUndo];
try
if FPartialSelectedItem<>nil then
FPartialSelectedItem.FinalizeUndoGroup
else if GetChosenItem<>nil then
GetChosenItem.FinalizeUndoGroup;
finally
State := State - [rvstFinalizingUndo];
end;
end;
if UndoList.BeginItem(UndoType, '', GetCurItemNo, GetOffsetInCurItem) then
UndoDest := udUndo
else
UndoDest := udNone;
end;
{------------------------------------------------------------------------------}
procedure TRVEditRVData.BeginNamedUndoSequence(UndoType: TRVUndoType; const Caption: String;
AllowFinalize: Boolean);
begin
if not (rvstFinalizingUndo in State) and AllowFinalize then begin
State := State + [rvstFinalizingUndo];
try
if FPartialSelectedItem<>nil then
FPartialSelectedItem.FinalizeUndoGroup
else if GetChosenItem<>nil then
GetChosenItem.FinalizeUndoGroup;
finally
State := State - [rvstFinalizingUndo];
end;
end;
if UndoList.BeginItem(UndoType, Caption, GetCurItemNo, GetOffsetInCurItem) then
UndoDest := udUndo
else
UndoDest := udNone;
end;
{------------------------------------------------------------------------------}
procedure TRVEditRVData.SetUndoGroupMode(GroupUndo: Boolean);
begin
if GroupUndo then
inc(UndoList.GroupModeCount)
else
dec(UndoList.GroupModeCount);
end;
{------------------------------------------------------------------------------}
procedure TRVEditRVData.EndUndoSequence;
begin
UndoList.EndItem;
end;
{------------------------------------------------------------------------------}
function TRVEditRVData.GetParaEndItemNo(ItemNo: Integer): Integer;
begin
Result := ItemNo+1;
while Result<Items.Count do begin
if GetItem(Result).CanBeBorderStart then break;
inc(Result)
end;
dec(Result);
end;
{------------------------------------------------------------------------------}
procedure TRVEditRVData.SetParaStyle(StartItemNo, EndItemNo, ParaNo: Integer;
var FullReformat: Boolean);
var i: Integer;
NewWidth, OldWidth: Integer;
item : TCustomRVItemInfo;
begin
OldWidth := CalculateParaSectionsMinWidthDef(StartItemNo, EndItemNo);
for i := StartItemNo to EndItemNo do begin
item := GetItem(i);
if not (rvpaoStyleProtect in GetRVStyle.ParaStyles[item.ParaNo].Options) or
((i>0) and (item.SameAsPrev or item.BR) and (GetItemPara(i-1)=ParaNo))
then
item.ParaNo := ParaNo;
end;
NewWidth := CalculateParaSectionsMinWidthDef(StartItemNo, EndItemNo);
FullReformat := {(OldWidth<>NewWidth) and}
((NewWidth>DocumentWidth) or
(OldWidth>=DocumentWidth));
end;
{------------------------------------------------------------------------------}
procedure TRVEditRVData.Do_ItemModifyTerminator(ItemNo: Integer; Opening: Boolean);
var ui: TRVUndoModifyItemTerminator;
List: TRVUndoList;
begin
List := GetUndoList;
if List<>nil then begin
ui := TRVUndoModifyItemTerminator.Create;
ui.ItemNo := ItemNo;
ui.Opening := Opening;
List.AddInfo(ui);
end;
end;
{------------------------------------------------------------------------------}
procedure TRVEditRVData.Do_ReformateRange(StartNo, EndNo: Integer;
SuperReformat: Boolean);
var ui: TRVUndoReformateRange;
List: TRVUndoList;
begin
List := GetUndoList;
if List<>nil then begin
ui := TRVUndoReformateRange.Create;
ui.Action := rvuMisc;
ui.ItemNo := StartNo;
ui.LastAffectedItemNo := EndNo;
ui.SuperReformat := SuperReformat;
List.AddInfo(ui);
end;
end;
{------------------------------------------------------------------------------}
procedure TRVEditRVData.Do_DeleteItem(ItemNo: Integer; var FullReformat: Boolean);
var ui: TRVUndoDeleteItemInfo;
item: TCustomRVItemInfo;
List: TRVUndoList;
LastAffectedItemNo: Integer;
FR: Boolean;
begin
item := GetItem(ItemNo);
FullReformat := CalculateMinItemWidthPlusEx(ItemNo)=DocumentWidth;
if item.Checkpoint<>nil then
Do_DeleteCP(ItemNo);
if False and (ItemNo>0) and item.CanBeBorderStart then
LastAffectedItemNo := GetParaEndItemNo(ItemNo)
else
LastAffectedItemNo := -1;
List := GetUndoList;
if List<>nil then begin
ui := TRVUndoDeleteItemInfo.Create;
ui.Action := rvuDeleteItem;
ui.Item := item;
//!!ui.RVData := Self;
ui.ItemNo := ItemNo;
ui.LastAffectedItemNo := LastAffectedItemNo;
ui.s := Items[ItemNo];
List.AddInfo(ui);
item.MovingToUndoList(ItemNo, Self, ui);
end
else begin
FreeItem(ItemNo, False);
end;
Items.Delete(ItemNo);
if (LastAffectedItemNo<>-1) then begin
Do_Para(ItemNo, LastAffectedItemNo-1,
GetItem(ItemNo-1).ParaNo, FR);
FullReformat := FR or FullReformat;
end;
end;
{------------------------------------------------------------------------------}
procedure TRVEditRVData.Do_ModifyItem(ItemNo: Integer; const s: String;
Item: TCustomRVItemInfo);
var ui: TRVUndoModifyItemInfo;
OldItem: TCustomRVItemInfo;
List: TRVUndoList;
begin
OldItem := GetItem(ItemNo);
Item.Checkpoint := OldItem.Checkpoint;
if Item.Checkpoint<>nil then
Item.Checkpoint.ItemInfo := Item;
OldItem.Checkpoint := nil;
if (rvoTagsArePChars in Options) and (Item.Tag=OldItem.Tag) then
Item.Tag := RV_CopyTag(OldItem.Tag,rvoTagsArePChars in Options);
Item.ParaNo := OldItem.ParaNo;
Item.ItemOptions := OldItem.ItemOptions;
Item.JumpID := OldItem.JumpID;
Item.DrawItemNo := OldItem.DrawItemNo;
if FActiveItem=OldItem then
FActiveItem := Item;
if FPartialSelectedItem=OldItem then
FPartialSelectedItem := Item;
List := GetUndoList;
if List<>nil then begin
ui := TRVUndoModifyItemInfo.Create;
ui.Action := rvuModifyItem;
ui.Item := OldItem;
//!!ui.RVData := Self;
ui.ItemNo := ItemNo;
ui.s := Items[ItemNo];
//OldItem.MovingToUndoList;
List.AddInfo(ui);
end
else begin
InternalFreeItem(OldItem, False); // never called for controls
end;
Items[ItemNo] := s;
Items.Objects[ItemNo] := Item;
end;
{------------------------------------------------------------------------------}
procedure TRVEditRVData.Do_DeleteItems(StartItemNo, EndItemNo: Integer; var FullReformat: Boolean);
var i: Integer;
item: TCustomRVItemInfo;
List: TRVUndoList;
ui: TRVUndoDeleteItemsInfo;
LastAffectedItemNo: Integer;
FR: Boolean;
begin
FullReformat := False;
if StartItemNo>EndItemNo then exit;
FullReformat := CalculateMinItemsWidthPlusEx(StartItemNo, EndItemNo)=DocumentWidth;
for i := EndItemNo downto StartItemNo do begin
item := GetItem(i);
if item.Checkpoint<>nil then
Do_DeleteCP(i);
end;
if False and (StartItemNo>0) then
LastAffectedItemNo := GetParaEndItemNo(EndItemNo)
else
LastAffectedItemNo := -1;
List := GetUndoList;
if List<>nil then begin
ui := TRVUndoDeleteItemsInfo.Create;
ui.Action := rvuDeleteItems;
ui.StartItemNo := StartItemNo;
ui.LastAffectedItemNo := LastAffectedItemNo;
List.AddInfo(ui);
for i := EndItemNo downto StartItemNo do begin
item := GetItem(i);
ui.List.AddObject(Items[i],item);
item.MovingToUndoList(i, Self, ui);
Items.Delete(i);
end;
end
else begin
for i := EndItemNo downto StartItemNo do begin
FreeItem(i, False);
Items.Delete(i);
end;
end;
if (LastAffectedItemNo<>-1) then begin
Do_Para(StartItemNo,LastAffectedItemNo-(EndItemNo-StartItemNo+1),
GetItemPara(StartItemNo-1), FR);
FullReformat := FullReformat or FR;
end;
end;
{------------------------------------------------------------------------------}
procedure TRVEditRVData.Do_DeleteSubstring(ItemNo, Index,ALength: Integer);
var s: String;
List: TRVUndoList;
ui: TRVUndoDeleteSubstringInfo;
begin
s := Items[ItemNo];
if ALength=-1 then
ALength := RVU_Length(s,GetItemOptions(ItemNo))-Index+1;
if ALength=0 then exit;
List := GetUndoList;
if List<>nil then begin
ui := TRVUndoDeleteSubstringInfo.Create;
ui.Action := rvuDeleteSubstring;
ui.ItemNo := ItemNo;
ui.Index := Index;
ui.s := RVU_Copy(Items[ItemNo],Index, ALength, GetItemOptions(ItemNo));
List.AddInfo(ui);
end;
RVU_Delete(s, Index, ALength, GetItemOptions(ItemNo));
ItemAction(rviaTextModifying, GetItem(ItemNo), s, Self);
Items[ItemNo] := s;
end;
{------------------------------------------------------------------------------}
procedure TRVEditRVData.Do_Para(FirstItemNo, EndItemNo, ParaNo: Integer;
var FullReformat: Boolean);
var List: TRVUndoList;
ui: TRVUndoParaListInfo;
i: Integer;
begin
FullReformat := False;
if EndItemNo<FirstItemNo then
exit;
List := GetUndoList;
if List<>nil then begin
ui := TRVUndoParaListInfo.Create;
ui.Action := rvuPara;
ui.StartItemNo := FirstItemNo;
for i := FirstItemNo to EndItemNo do
ui.List.Add(GetItemPara(i));
List.AddInfo(ui);
end;
SetParaStyle(FirstItemNo, EndItemNo, ParaNo, FullReformat);
end;
{------------------------------------------------------------------------------}
procedure TRVEditRVData.Do_ParaList(FirstItemNo: Integer; ParaList: TRVIntegerList;
var FullReformat: Boolean);
var List: TRVUndoList;
ui: TRVUndoParaInfo;
i: Integer;
NewWidth, OldWidth: Integer;
begin
FullReformat := False;
if ParaList.Count=0 then
exit;
List := GetUndoList;
if List<>nil then begin
ui := TRVUndoParaInfo.Create;
ui.Action := rvuPara;
ui.ItemNo := FirstItemNo;
ui.Count := ParaList.Count;
ui.ParaNo := GetItemPara(FirstItemNo);
for i := 0 to ParaList.Count-1 do
if not GetItem(FirstItemNo+i).GetBoolValue(rvbpFullWidth) then begin
ui.ParaNo := GetItemPara(FirstItemNo+i);
break;
end;
List.AddInfo(ui);
end;
OldWidth := CalculateMinItemsWidthPlusEx(FirstItemNo, FirstItemNo+ParaList.Count-1);
for i := 0 to ParaList.Count-1 do
GetItem(FirstItemNo+i).ParaNo := ParaList[i];
NewWidth := CalculateMinItemsWidthPlusEx(FirstItemNo, FirstItemNo+ParaList.Count-1);
FullReformat := (OldWidth<>NewWidth) and
((NewWidth>DocumentWidth) or
(OldWidth>=DocumentWidth));
end;
{------------------------------------------------------------------------------}
procedure TRVEditRVData.Do_StyleNo(ItemNo, StyleNo: Integer);
var List: TRVUndoList;
ui: TRVUndoStyleNoInfo;
item :TCustomRVItemInfo;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -