From be2415693b95dc3a3618261bb36ee0096971758d Mon Sep 17 00:00:00 2001 From: peter Date: Sat, 20 Feb 1999 15:18:25 +0000 Subject: [PATCH] + ctrl-c capture with confirm dialog + ascii table in the tools menu + heapviewer * empty file fixed * fixed callback routines in fpdebug to have far for tp7 --- ide/text/fp.pas | 15 +++-- ide/text/fpcalc.pas | 11 +++- ide/text/fpcatch.pas | 92 +++++++++++++++++++++++++++ ide/text/fpconst.pas | 15 ++++- ide/text/fpdebug.pas | 24 ++++--- ide/text/fpide.pas | 33 +++++++++- ide/text/fpmtools.inc | 19 +++++- ide/text/fpredir.pas | 20 ++++-- ide/text/weditor.pas | 142 ++++++++++++++++++++++++++---------------- ide/text/whelp.pas | 11 +++- ide/text/whtml.pas | 2 + 11 files changed, 301 insertions(+), 83 deletions(-) create mode 100644 ide/text/fpcatch.pas diff --git a/ide/text/fp.pas b/ide/text/fp.pas index 80e12d4ced..8a592b9567 100644 --- a/ide/text/fp.pas +++ b/ide/text/fp.pas @@ -22,11 +22,7 @@ uses Dos, BrowCol, FPIni,FPViews,FPConst,FPVars,FPUtils,FPIde,FPHelp,FPSwitch,FPUsrScr, - FPTools,FPDebug,FPTemplt -{$ifdef TEMPHEAP} - ,dpmiexcp -{$endif TEMPHEAP} - ; + FPTools,FPDebug,FPTemplt,FPCatch; procedure ProcessParams(BeforeINI: boolean); @@ -111,7 +107,14 @@ BEGIN END. { $Log$ - Revision 1.11 1999-02-18 13:44:30 peter + Revision 1.12 1999-02-20 15:18:25 peter + + ctrl-c capture with confirm dialog + + ascii table in the tools menu + + heapviewer + * empty file fixed + * fixed callback routines in fpdebug to have far for tp7 + + Revision 1.11 1999/02/18 13:44:30 peter * search fixed + backward search * help fixes diff --git a/ide/text/fpcalc.pas b/ide/text/fpcalc.pas index cdfdcfdef4..76a9cd727e 100644 --- a/ide/text/fpcalc.pas +++ b/ide/text/fpcalc.pas @@ -93,7 +93,7 @@ const procedure TCalcButton.HandleEvent(var Event: TEvent); var Call : boolean; - i : Sw_Word; + i : longint; begin Call:=true; case Event.What of @@ -423,7 +423,14 @@ end; end. { $Log$ - Revision 1.1 1998-12-22 14:27:54 peter + Revision 1.2 1999-02-20 15:18:27 peter + + ctrl-c capture with confirm dialog + + ascii table in the tools menu + + heapviewer + * empty file fixed + * fixed callback routines in fpdebug to have far for tp7 + + Revision 1.1 1998/12/22 14:27:54 peter * moved Revision 1.2 1998/12/22 10:39:39 peter diff --git a/ide/text/fpcatch.pas b/ide/text/fpcatch.pas new file mode 100644 index 0000000000..05021a70b2 --- /dev/null +++ b/ide/text/fpcatch.pas @@ -0,0 +1,92 @@ +{ + $Id$ + Copyright (c) 1997-98 by Michael Van Canneyt + + Unit to catch segmentation faults and Ctrl-C and exit gracefully + under linux and go32v2 + + See the file COPYING.FPC, included in this distribution, + for details about the copyright. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + **********************************************************************} +Unit fpcatch; +interface + +{$ifdef linux} +{$define has_signal} +uses + linux; +{$endif} +{$ifdef go32v2} +{$define has_signal} +uses + dpmiexcp; +{$endif} + +{$ifdef has_signal} +Var + NewSignal,OldSigSegm,OldSigInt : SignalHandler; +{$endif} + + +Implementation + +uses + commands,msgbox, + fpide,fpviews; + + +{$ifdef has_signal} +{$ifdef linux} +Procedure CatchSignal(Sig : Integer);cdecl; +{$else} +Function CatchSignal(Sig : longint):longint; +{$endif} +begin + case Sig of + SIGSEGV : begin + MyApp.Done; + Writeln('Internal Error caught'); + Halt; + end; + SIGINT : begin + if MessageBox(#3'Do You really want to quit?',nil,mferror+mfyesbutton+mfnobutton)=cmYes then + begin + MyApp.Done; + Halt; + end; + end; + end; +{$ifndef linux} + CatchSignal:=0; +{$endif} +end; +{$endif def has_signal} + + +begin +{$ifdef has_signal} +{$ifndef TP} + NewSignal:=SignalHandler(@CatchSignal); +{$else TP} + NewSignal:=SignalHandler(CatchSignal); +{$endif TP} + OldSigSegm:=Signal (SIGSEGV,NewSignal); + OldSigInt:=Signal (SIGINT,NewSignal); +{$endif} +end. + +{ + $Log$ + Revision 1.1 1999-02-20 15:18:28 peter + + ctrl-c capture with confirm dialog + + ascii table in the tools menu + + heapviewer + * empty file fixed + * fixed callback routines in fpdebug to have far for tp7 + +} diff --git a/ide/text/fpconst.pas b/ide/text/fpconst.pas index cdabdc89c1..641e1cf442 100644 --- a/ide/text/fpconst.pas +++ b/ide/text/fpconst.pas @@ -78,7 +78,7 @@ const cmResetDebugger = 228; cmContToCursor = 229; cmOpenGDBWindow = 230; - + cmNotImplemented = 1000; cmNewFromTemplate = 1001; @@ -99,6 +99,7 @@ const cmUserScreenWindow = 1651; cmEvaluate = 1652; cmCalculator = 1653; + cmAsciiTable = 1654; cmToolsMessages = 1700; cmToolsBase = 1800; @@ -172,6 +173,7 @@ const hcSaveINI = hcShift+cmSaveINI; hcSaveAsINI = hcShift+cmSaveAsINI; hcCalculator = hcShift+cmCalculator; + hcAsciiTable = hcShift+cmAsciiTable; hcGrep = hcShift+cmGrep; hcSwitchesMode = hcShift+cmSwitchesMode; hcAbout = hcShift+cmAbout; @@ -254,7 +256,7 @@ const #6#12; CGDBInputLine = #9#9#10#11#12; - + CIDEAppColor = CAppColor + { CIDEHelpDialog } {128-143}#$70#$7F#$7A#$13#$13#$70#$70#$7F#$7E#$20#$2B#$2F#$78#$2E#$70#$30 + { 1-16} @@ -273,7 +275,14 @@ implementation END. { $Log$ - Revision 1.10 1999-02-11 19:07:19 pierre + Revision 1.11 1999-02-20 15:18:28 peter + + ctrl-c capture with confirm dialog + + ascii table in the tools menu + + heapviewer + * empty file fixed + * fixed callback routines in fpdebug to have far for tp7 + + Revision 1.10 1999/02/11 19:07:19 pierre * GDBWindow redesigned : normal editor apart from that any kbEnter will send the line (for begin to cursor) diff --git a/ide/text/fpdebug.pas b/ide/text/fpdebug.pas index 9777142400..c3293c4f0d 100644 --- a/ide/text/fpdebug.pas +++ b/ide/text/fpdebug.pas @@ -128,7 +128,8 @@ begin end; procedure TDebugController.InsertBreakpoints; - procedure DoInsert(PB : PBreakpoint); + + procedure DoInsert(PB : PBreakpoint);{$ifndef FPC}far;{$endif} begin PB^.Insert; end; @@ -139,16 +140,18 @@ end; procedure TDebugController.RemoveBreakpoints; - procedure DoDelete(PB : PBreakpoint); + + procedure DoDelete(PB : PBreakpoint);{$ifndef FPC}far;{$endif} begin PB^.Remove; end; + begin BreakpointCollection^.ForEach(@DoDelete); end; procedure TDebugController.ResetBreakpointsValues; - procedure DoResetVal(PB : PBreakpoint); + procedure DoResetVal(PB : PBreakpoint);{$ifndef FPC}far;{$endif} begin PB^.ResetValues; end; @@ -544,7 +547,7 @@ end; procedure TBreakpointCollection.ShowBreakpoints(W : PSourceWindow); - procedure SetInSource(P : PBreakpoint); + procedure SetInSource(P : PBreakpoint);{$ifndef FPC}far;{$endif} begin If assigned(P^.FileName) and (P^.FileName^=W^.Editor^.FileName) then W^.Editor^.SetLineBreakState(P^.Line,P^.state=bs_enabled); @@ -556,7 +559,7 @@ end; function TBreakpointCollection.GetType(typ : BreakpointType;Const s : String) : PBreakpoint; - function IsThis(P : PBreakpoint) : boolean; + function IsThis(P : PBreakpoint) : boolean;{$ifndef FPC}far;{$endif} begin IsThis:=(P^.typ=typ) and (P^.Name^=S); end; @@ -569,7 +572,7 @@ function TBreakpointCollection.ToggleFileLine(Const FileName: String;LineNr : Lo var PB : PBreakpoint; - function IsThere(P : PBreakpoint) : boolean; + function IsThere(P : PBreakpoint) : boolean;{$ifndef FPC}far;{$endif} begin IsThere:=(P^.typ=bt_file_line) and (P^.FileName^=FileName) and (P^.Line=LineNr); end; @@ -676,7 +679,14 @@ end. { $Log$ - Revision 1.14 1999-02-16 12:47:36 pierre + Revision 1.15 1999-02-20 15:18:29 peter + + ctrl-c capture with confirm dialog + + ascii table in the tools menu + + heapviewer + * empty file fixed + * fixed callback routines in fpdebug to have far for tp7 + + Revision 1.14 1999/02/16 12:47:36 pierre * GDBWindow does not popup on F7 or F8 anymore Revision 1.13 1999/02/16 10:43:54 peter diff --git a/ide/text/fpide.pas b/ide/text/fpide.pas index 42544977d3..eeb5abe0d7 100644 --- a/ide/text/fpide.pas +++ b/ide/text/fpide.pas @@ -17,14 +17,16 @@ unit fpide; interface uses - Drivers,Views,App, + Drivers,Views,App,Gadgets, {$ifdef EDITORS}Editors,{$else}WEditor,{$endif} Comphook, FPViews; type TIDEApp = object(TApplication) + Heap : PHeapView; constructor Init; + procedure Idle;virtual; procedure InitMenuBar; virtual; procedure InitStatusLine; virtual; procedure Open(FileName: string); @@ -60,6 +62,7 @@ type procedure DoOpenGDBWindow; procedure DoToggleBreak; procedure Information; + procedure DoAsciiTable; procedure Calculator; procedure ExecuteTool(Idx: integer); procedure SetSwitchesMode; @@ -112,6 +115,7 @@ uses {$endif} Video,Mouse,Keyboard, Dos,Objects,Memory,Menus,Dialogs,StdDlg,ColorSel,Commands,HelpCtx, + AsciiTab, Systems,BrowCol, WHelp,WHlpView,WINI, FPConst,FPVars,FPUtils,FPSwitch,FPIni,FPIntf,FPCompile,FPHelp, @@ -129,6 +133,8 @@ begin end; constructor TIDEApp.Init; +var + R : TRect; begin {$ifndef EDITORS} UseSyntaxHighlight:=IDEUseSyntaxHighlight; @@ -144,6 +150,18 @@ begin Desktop^.Insert(ProgramInfoWindow); Message(@Self,evBroadcast,cmUpdate,nil); CurDirChanged; +{ heap viewer } + GetExtent(R); + Dec(R.B.X); + R.A.X := R.B.X - 9; R.A.Y := R.B.Y - 1; + Heap := New(PHeapView, InitKb(R)); + Insert(Heap); +end; + +procedure TIDEApp.Idle; +begin + inherited Idle; + Heap^.Update; end; procedure TIDEApp.InitMenuBar; @@ -216,7 +234,8 @@ begin NewLine( NewItem('~G~rep', 'Shift+F2', kbShiftF2, cmGrep, hcGrep, NewItem('~C~alculator', '', kbNoKey, cmCalculator, hcCalculator, - nil))))), + NewItem('Ascii ~t~able', '', kbNoKey, cmAsciiTable, hcAsciiTable, + nil)))))), NewSubMenu('~O~ptions', hcOptionsMenu, NewMenu( NewItem('Mode~.~..','', kbNoKey, cmSwitchesMode, hcSwitchesMode, NewItem('~C~ompiler...','', kbNoKey, cmCompiler, hcCompiler, @@ -375,6 +394,7 @@ begin cmSaveINI : SaveINI; cmSaveAsINI : SaveAsINI; { -- Tools menu -- } + cmAsciiTable : DoAsciiTable; cmCalculator : Calculator; cmGrep : Grep; cmToolsBase+1.. @@ -662,7 +682,14 @@ end; END. { $Log$ - Revision 1.16 1999-02-18 13:44:31 peter + Revision 1.17 1999-02-20 15:18:30 peter + + ctrl-c capture with confirm dialog + + ascii table in the tools menu + + heapviewer + * empty file fixed + * fixed callback routines in fpdebug to have far for tp7 + + Revision 1.16 1999/02/18 13:44:31 peter * search fixed + backward search * help fixes diff --git a/ide/text/fpmtools.inc b/ide/text/fpmtools.inc index f93d784e58..77770a54ec 100644 --- a/ide/text/fpmtools.inc +++ b/ide/text/fpmtools.inc @@ -14,6 +14,16 @@ **********************************************************************} +procedure TIDEApp.DoAsciiTable; +var + P: PAsciiChart; +begin + P := New(PAsciiChart, Init); + P^.HelpCtx := hcAsciiTable; + InsertWindow(P); +end; + + procedure TIDEApp.Calculator; begin with CalcWindow^ do @@ -127,7 +137,14 @@ begin end; { $Log$ - Revision 1.6 1999-02-05 13:51:42 peter + Revision 1.7 1999-02-20 15:18:31 peter + + ctrl-c capture with confirm dialog + + ascii table in the tools menu + + heapviewer + * empty file fixed + * fixed callback routines in fpdebug to have far for tp7 + + Revision 1.6 1999/02/05 13:51:42 peter * unit name of FPSwitches -> FPSwitch which is easier to use * some fixes for tp7 compiling diff --git a/ide/text/fpredir.pas b/ide/text/fpredir.pas index 3e4df26f17..d9c4a31c18 100644 --- a/ide/text/fpredir.pas +++ b/ide/text/fpredir.pas @@ -72,20 +72,23 @@ Type Var PrefSeg : Word; +{$IfDef MsDos} MinBlockSize : Word; - FName : PathStr; - F,FE : File; MyBlockSize : Word; +{$endif} + F,FE : File; RedirChanged : Boolean; RedirErrorChanged : Boolean; - Handles : PHandles; OldHandle,OldErrorHandle : Byte; +{$ifdef UseDUP} TempH, TempErrorH : longint; +{$endif} {$ifdef FPC} HandlesOffset : word; +{$else} + Handles : PHandles; {$endif FPC} - function dup(fh : longint) : longint; var Regs : Registers; @@ -377,7 +380,14 @@ Begin End. { $Log$ - Revision 1.6 1999-02-05 13:51:43 peter + Revision 1.7 1999-02-20 15:18:32 peter + + ctrl-c capture with confirm dialog + + ascii table in the tools menu + + heapviewer + * empty file fixed + * fixed callback routines in fpdebug to have far for tp7 + + Revision 1.6 1999/02/05 13:51:43 peter * unit name of FPSwitches -> FPSwitch which is easier to use * some fixes for tp7 compiling diff --git a/ide/text/weditor.pas b/ide/text/weditor.pas index 4aa0d18e6b..c5793602ba 100644 --- a/ide/text/weditor.pas +++ b/ide/text/weditor.pas @@ -778,10 +778,12 @@ end; PLine,TLineCollection *****************************************************************************} -function NewLine(S: string): PLine; -var P: PLine; +function NewLine(const S: string): PLine; +var + P: PLine; begin - New(P); FillChar(P^,SizeOf(P^),0); + New(P); + FillChar(P^,SizeOf(P^),0); P^.Text:=NewStr(S); NewLine:=P; end; @@ -883,6 +885,8 @@ constructor TCodeEditor.Init(var Bounds: TRect; AHScrollBar, AVScrollBar: begin inherited Init(Bounds,AHScrollBar,AVScrollBar); New(Lines, Init(500,1000)); + { we have always need at least 1 line } + Lines^.Insert(NewLine('')); SetState(sfCursorVis,true); SetFlags(DefaultCodeEditorFlags); TabSize:=DefaultTabSize; SetHighlightRow(-1); @@ -1683,50 +1687,66 @@ begin end; function TCodeEditor.InsertLine: Sw_integer; -var Ind: Sw_integer; - S,IndentStr: string; -procedure CalcIndent(LineOver: Sw_integer); -begin - if (LineOver<0) or (LineOver>GetLineCount) then Ind:=0 else +var + SelBack,Ind: Sw_integer; + S,IndentStr: string; + + procedure CalcIndent(LineOver: Sw_integer); begin - IndentStr:=GetLineText(LineOver); - Ind:=0; - while (IndGetLineCount) then Ind:=0 else + begin + IndentStr:=GetLineText(LineOver); + Ind:=0; + while (Ind0 then - begin - S:=GetDisplayText(CurPos.Y); - SelBack:=length(S)-SelEnd.X; - SetDisplayText(CurPos.Y,RTrim(S)); - end; - CalcIndent(CurPos.Y); - Lines^.AtInsert(CurPos.Y+1,NewLine(IndentStr+copy(S,CurPos.X+1,255))); - LimitsChanged; - SetDisplayText(CurPos.Y,copy(S,1,CurPos.X-1+1)); - if PointOfs(SelStart)<>PointOfs(SelEnd) then { !!! check it - it's buggy !!! } - begin SelEnd.Y:=CurPos.Y+1; SelEnd.X:=length(GetLineText(CurPos.Y+1))-SelBack; end; - UpdateAttrs(CurPos.Y,attrAll); - SetCurPtr(Ind,CurPos.Y+1); - end else - begin - if CurPos.Y=GetLineCount-1 then - CalcIndent(CurPos.Y); - begin - Lines^.Insert(NewLine(IndentStr)); - LimitsChanged; - end; - SetCurPtr(Ind,CurPos.Y+1); - end; + begin + SelBack:=0; + if GetLineCount>0 then + begin + S:=GetDisplayText(CurPos.Y); + SelBack:=length(S)-SelEnd.X; + SetDisplayText(CurPos.Y,RTrim(S)); + CalcIndent(CurPos.Y); + Lines^.AtInsert(CurPos.Y+1,NewLine(IndentStr+copy(S,CurPos.X+1,255))); + end + else + begin + CalcIndent(0); + Lines^.Insert(NewLine(IndentStr)); + end; + LimitsChanged; + SetDisplayText(CurPos.Y,copy(S,1,CurPos.X-1+1)); + if PointOfs(SelStart)<>PointOfs(SelEnd) then { !!! check it - it's buggy !!! } + begin + SelEnd.Y:=CurPos.Y+1; + SelEnd.X:=length(GetLineText(CurPos.Y+1))-SelBack; + end; + UpdateAttrs(CurPos.Y,attrAll); + SetCurPtr(Ind,CurPos.Y+1); + end + else + begin + if CurPos.Y=GetLineCount-1 then + CalcIndent(CurPos.Y); + Lines^.Insert(NewLine(IndentStr)); + LimitsChanged; + SetCurPtr(Ind,CurPos.Y+1); + end; DrawLines(CurPos.Y); end; @@ -1739,11 +1759,11 @@ begin begin if CurPos.Y>0 then begin - S:=GetLineText(CurPos.Y-1); - SetLineText(CurPos.Y-1,S+GetLineText(CurPos.Y)); - Lines^.AtDelete(CurPos.Y); - LimitsChanged; - SetCurPtr(length(S),CurPos.Y-1); + S:=GetLineText(CurPos.Y-1); + SetLineText(CurPos.Y-1,S+GetLineText(CurPos.Y)); + Lines^.AtDelete(CurPos.Y); + LimitsChanged; + SetCurPtr(length(S),CurPos.Y-1); end; end else @@ -2833,12 +2853,17 @@ begin Reset(f); {$ifdef TPUNIXLF}OnlyLF:=true;{$endif} OK:=(IOResult=0); - while OK and (Eof(f)=false) and (GetLineCount