From 029d4f632736a02bbd9bcb48f7678d26ae49df5e Mon Sep 17 00:00:00 2001 From: mattias Date: Wed, 25 Apr 2007 16:37:19 +0000 Subject: [PATCH] added package prettymessages - an IDE add-on to reduce FPC hints git-svn-id: trunk@11002 - --- .gitattributes | 9 + components/codetools/basiccodetools.pas | 8 +- components/codetools/sourcelog.pas | 4 +- components/codetools/stdcodetools.pas | 6 +- components/opengl/glgtk2glxcontext.pas | 1 - components/opengl/glgtkglxcontext.pas | 71 ++++-- components/opengl/openglcontext.pas | 2 +- components/prettymessages/README.txt | 7 + components/prettymessages/hidefpchints.pas | 203 ++++++++++++++++++ components/prettymessages/prettymessages.lpk | 56 +++++ components/prettymessages/prettymessages.pas | 21 ++ .../prettymessages/prettymsgoptions.pas | 49 +++++ .../prettymessages/prettymsgoptionsdlg.lfm | 30 +++ .../prettymessages/prettymsgoptionsdlg.lrs | 13 ++ .../prettymessages/prettymsgoptionsdlg.pas | 74 +++++++ ide/msgview.pp | 42 +++- ideintf/idemsgintf.pas | 8 +- ideintf/srceditorintf.pas | 1 + lcl/controls.pp | 2 +- packager/globallinks/prettymessages-0.lpl | 2 + packager/packageeditor.pas | 24 +-- 21 files changed, 587 insertions(+), 46 deletions(-) create mode 100644 components/prettymessages/README.txt create mode 100644 components/prettymessages/hidefpchints.pas create mode 100644 components/prettymessages/prettymessages.lpk create mode 100644 components/prettymessages/prettymessages.pas create mode 100644 components/prettymessages/prettymsgoptions.pas create mode 100644 components/prettymessages/prettymsgoptionsdlg.lfm create mode 100644 components/prettymessages/prettymsgoptionsdlg.lrs create mode 100644 components/prettymessages/prettymsgoptionsdlg.pas create mode 100644 packager/globallinks/prettymessages-0.lpl diff --git a/.gitattributes b/.gitattributes index bccfcc6270..7aa8bcd328 100644 --- a/.gitattributes +++ b/.gitattributes @@ -333,6 +333,14 @@ components/prettyformat/pfidesource.pas svneol=native#text/plain components/prettyformat/prettyformat.lpk svneol=native#text/plain components/prettyformat/prettyformat.pas svneol=native#text/plain components/prettyformat/ptopu.pp svneol=native#text/plain +components/prettymessages/README.txt svneol=native#text/plain +components/prettymessages/hidefpchints.pas svneol=native#text/plain +components/prettymessages/prettymessages.lpk svneol=native#text/plain +components/prettymessages/prettymessages.pas svneol=native#text/plain +components/prettymessages/prettymsgoptions.pas svneol=native#text/plain +components/prettymessages/prettymsgoptionsdlg.lfm svneol=native#text/plain +components/prettymessages/prettymsgoptionsdlg.lrs svneol=native#text/plain +components/prettymessages/prettymsgoptionsdlg.pas svneol=native#text/plain components/printers/Makefile svneol=native#text/plain components/printers/Makefile.fpc svneol=native#text/plain components/printers/design/Makefile svneol=native#text/plain @@ -2843,6 +2851,7 @@ packager/globallinks/lazopenglcontext-0.lpl svneol=native#text/plain packager/globallinks/macosfiles-0.lpl svneol=native#text/plain packager/globallinks/popupnotifierlaz-0.lpl svneol=native#text/plain packager/globallinks/prettyformat-0.lpl svneol=native#text/plain +packager/globallinks/prettymessages-0.lpl svneol=native#text/plain packager/globallinks/printer4lazarus-0.5.lpl svneol=native#text/plain packager/globallinks/printers4lazide-0.lpl svneol=native#text/plain packager/globallinks/projtemplates-0.lpl svneol=native#text/plain diff --git a/components/codetools/basiccodetools.pas b/components/codetools/basiccodetools.pas index 14c0e8def2..3b789081f3 100644 --- a/components/codetools/basiccodetools.pas +++ b/components/codetools/basiccodetools.pas @@ -54,7 +54,7 @@ function FindNextIncludeDirective(const ASource: string; out FilenameStartPos, FileNameEndPos, CommentStartPos, CommentEndPos: integer): integer; function FindNextIDEDirective(const ASource: string; StartPos: integer; - NestedComments: boolean): integer; + NestedComments: boolean; EndPos: integer = 0): integer; function CleanCodeFromComments(const DirtyCode: string; NestedComments: boolean): string; function FindMainUnitHint(const ASource: string; var Filename: string): boolean; @@ -2400,11 +2400,13 @@ begin end; function FindNextIDEDirective(const ASource: string; StartPos: integer; - NestedComments: boolean): integer; + NestedComments: boolean; EndPos: integer): integer; var MaxPos: integer; begin MaxPos:=length(ASource); + if (EndPos>0) and (EndPos<=MaxPos) then + MaxPos:=EndPos-1; Result:=StartPos; while (Result<=MaxPos) do begin case ASource[Result] of @@ -2453,7 +2455,7 @@ begin end; end; - if Result>MaxPos+1 then Result:=MaxPos+1; + Result:=-1; end; function CleanCodeFromComments(const DirtyCode: string; diff --git a/components/codetools/sourcelog.pas b/components/codetools/sourcelog.pas index bedab578ed..e7dcd1c869 100644 --- a/components/codetools/sourcelog.pas +++ b/components/codetools/sourcelog.pas @@ -111,7 +111,7 @@ type Data: Pointer; function LineCount: integer; function GetLine(Index: integer): string; - procedure GetLineRange(Index: integer; var LineRange: TLineRange); + procedure GetLineRange(Index: integer; out LineRange: TLineRange); property Items[Index: integer]: TSourceLogEntry read GetItems write SetItems; default; function Count: integer; // # Items @@ -286,7 +286,7 @@ begin Result:=''; end; -procedure TSourceLog.GetLineRange(Index: integer; var LineRange: TLineRange); +procedure TSourceLog.GetLineRange(Index: integer; out LineRange: TLineRange); begin BuildLineRanges; LineRange:=FLineRanges[Index]; diff --git a/components/codetools/stdcodetools.pas b/components/codetools/stdcodetools.pas index 065fbe69db..5dcea830a5 100644 --- a/components/codetools/stdcodetools.pas +++ b/components/codetools/stdcodetools.pas @@ -3396,7 +3396,7 @@ begin EndPos:=1; repeat StartPos:=FindNextIDEDirective(Src,EndPos,Scanner.NestedComments); - if StartPos>SrcLen then break; + if StartPos<1 then break; EndPos:=FindCommentEnd(Src,StartPos,Scanner.NestedComments); DirectiveList.Add(copy(Src,StartPos,EndPos-StartPos)); if EndPos>SrcLen then break; @@ -3421,7 +3421,7 @@ begin // find first old IDE directive InsertPos:=FindNextIDEDirective(Src,1,Scanner.NestedComments); - if InsertPos>SrcLen then InsertPos:=0; + if InsertPos<1 then InsertPos:=0; // remove all old IDE directives if InsertPos>=1 then @@ -3431,7 +3431,7 @@ begin repeat // find next IDE directive StartPos:=FindNextIDEDirective(Src,EndPos,Scanner.NestedComments); - if StartPos>SrcLen then break; + if StartPos<1 then break; EndPos:=FindCommentEnd(Src,StartPos,Scanner.NestedComments); // remove also space in front of directive while (StartPos>1) and (Src[StartPos-1] in [' ',#9]) do dec(StartPos); diff --git a/components/opengl/glgtk2glxcontext.pas b/components/opengl/glgtk2glxcontext.pas index a8edcefd63..cb23ab1c7c 100644 --- a/components/opengl/glgtk2glxcontext.pas +++ b/components/opengl/glgtk2glxcontext.pas @@ -66,7 +66,6 @@ var begin if (not AWinControl.HandleAllocated) then exit; Widget:=PGtkWidget(AWinControl.Handle); - if not GTK_WIDGET_MAPPED(Widget) then exit; Info:=PLOpenGLInfo(gtk_object_get_data(PGtkObject(Widget),'LOpenGLInfo')); DebugLn(['InternalResizeWnd ',dbgs(AWinControl.BoundsRect)]); diff --git a/components/opengl/glgtkglxcontext.pas b/components/opengl/glgtkglxcontext.pas index e8d3d64904..42036cf6c1 100644 --- a/components/opengl/glgtkglxcontext.pas +++ b/components/opengl/glgtkglxcontext.pas @@ -25,7 +25,7 @@ uses Classes, SysUtils, LCLProc, LCLType, X, XUtil, XLib, gl, InterfaceBase, WSLCLClasses, GtkWSControls, {$IFDEF LCLGTK2} - gdk2x, glib2, gdk2, gtk2, Gtk2Int, + GtkDef, gdk2x, glib2, gdk2, gtk2, Gtk2Int, {$ENDIF} {$IFDEF LCLGTK} glib, gdk, gtk, GtkInt, @@ -74,9 +74,9 @@ type function gdk_gl_query: boolean; function gdk_gl_choose_visual(attrlist: Plongint): PGdkVisual; function gdk_gl_get_config(visual: PGdkVisual; attrib: longint):longint; -function gdk_gl_context_new(visual: PGdkVisual): PGdkGLContext; +function gdk_gl_context_new(visual: PGdkVisual; attrlist: PlongInt): PGdkGLContext; function gdk_gl_context_share_new(visual: PGdkVisual; sharelist: PGdkGLContext; - direct: Integer): PGdkGLContext; + direct: Integer; attrlist: plongint): PGdkGLContext; function gdk_gl_context_attrlist_share_new(attrlist: Plongint; sharelist: PGdkGLContext; direct: Integer): PGdkGLContext; function gdk_gl_context_ref(context: PGdkGLContext): PGdkGLContext; @@ -274,6 +274,7 @@ begin DebugLn('get_xvisualinfo dpy=',XDisplayAsString(dpy)); DebugLn('get_xvisualinfo visual=',GdkVisualAsString(Visual)); + RaiseGDBException('not implemented for gtk2'); {$ENDIF} // 'GLX uses VisualInfo records because they uniquely identify @@ -341,6 +342,11 @@ var vi: PXVisualInfo; visual: PGdkVisual; begin + {$IFDEF lclgtk2} + DebugLn(['gdk_gl_choose_visual not implemented yet for gtk2']); + RaiseGDBException(''); + {$ENDIF} + //writeln('gdk_gl_choose_visual A '); if attrList=nil then begin Result:=nil; @@ -381,13 +387,13 @@ begin XFree(vi); end; -function gdk_gl_context_new(visual: PGdkVisual): PGdkGLContext; +function gdk_gl_context_new(visual: PGdkVisual; attrlist: PlongInt): PGdkGLContext; begin - Result:=gdk_gl_context_share_new(visual,nil,0); + Result:=gdk_gl_context_share_new(visual,nil,0,attrlist); end; function gdk_gl_context_share_new(visual: PGdkVisual; sharelist: PGdkGLContext; - direct: integer): PGdkGLContext; + direct: integer; attrlist: plongint): PGdkGLContext; var dpy: PDisplay; vi: PXVisualInfo; @@ -396,18 +402,25 @@ var glxcontext: TGLXContext; begin Result:=nil; - if visual=nil then exit; - - vi := get_xvisualinfo(visual); dpy := GetDefaultXDisplay; + {$IFDEF lclgtk2} + DebugLn(['gdk_gl_context_share_new AAA1']); + vi:=glXChooseVisual(dpy, DefaultScreen(dpy), @attrList[0]); + DebugLn(['gdk_gl_context_share_new AAA2']); + {$ELSE} + if visual=nil then exit; + vi := get_xvisualinfo(visual); + {$ENDIF} + PrivateShareList:=PGdkGLContextPrivate(sharelist); if (sharelist<>nil) then glxcontext := glXCreateContext(dpy, vi, PrivateShareList^.glxcontext, direct=1) else glxcontext := glXCreateContext(dpy, vi, nil, direct=1); + DebugLn(['gdk_gl_context_share_new AAA3']); XFree(vi); if (glxcontext = nil) then exit; @@ -425,11 +438,16 @@ function gdk_gl_context_attrlist_share_new(attrlist: Plongint; var visual: PGdkVisual; begin + {$IFDEF lclgtk2} + visual :=nil; + Result:=gdk_gl_context_share_new(visual, sharelist, direct,attrlist); + {$ELSE} visual := gdk_gl_choose_visual(attrlist); if (visual<>nil) then - Result:=gdk_gl_context_share_new(visual, sharelist, direct) + Result:=gdk_gl_context_share_new(visual, sharelist, direct,attrlist) else Result:=nil; + {$ENDIF} end; function gdk_gl_context_ref(context: PGdkGLContext): PGdkGLContext; @@ -513,10 +531,13 @@ procedure gtk_gl_area_init( ); cdecl; begin if theClass=nil then ; + DebugLn(['gtk_gl_area_init START']); PGtkGLArea(gl_area)^.glcontext:=nil; - {$IFDEF Gtk2} + {$IFDEF LclGtk2} gtk_widget_set_double_buffered(PGtkWidget(gl_area),gdkFALSE); + GTK_WIDGET_UNSET_FLAGS(PGtkWidget(gl_area),GTK_NO_WINDOW); {$ENDIF} + DebugLn(['gtk_gl_area_init END']); end; function GTK_TYPE_GL_AREA: TGtkType; @@ -600,36 +621,48 @@ var gl_area: PGtkGLArea; begin Result:=nil; + DebugLn(['gtk_gl_area_share_new START']); //writeln('gtk_gl_area_share_new A '); if (share<>nil) and (not GTK_IS_GL_AREA(share)) then exit; {$IFNDEF MSWindows} //writeln('gtk_gl_area_share_new B '); + {$IFDEF lclgtk2} + visual := nil; + {$ELSE} visual := gdk_gl_choose_visual(attrlist); if (visual = nil) then exit; + {$ENDIF} {$ENDIF non MSWindows} //writeln('gtk_gl_area_share_new C '); + DebugLn(['gtk_gl_area_share_new BBB1']); sharelist := nil; if share<>nil then sharelist:=share^.glcontext; - glcontext := gdk_gl_context_share_new(visual, sharelist, 1); + glcontext := gdk_gl_context_share_new(visual, sharelist, 1, attrlist); if (glcontext = nil) then exit; + DebugLn(['gtk_gl_area_share_new BBB2']); //writeln('gtk_gl_area_share_new D '); {$IFNDEF MSWindows} - // use colormap and visual suitable for OpenGL rendering - gtk_widget_push_colormap(gdk_colormap_new(visual,gtk_TRUE)); - gtk_widget_push_visual(visual); + if visual<>nil then begin + // use colormap and visual suitable for OpenGL rendering + gtk_widget_push_colormap(gdk_colormap_new(visual,gtk_TRUE)); + gtk_widget_push_visual(visual); + end; {$ENDIF non MSWindows} gl_area := gtk_type_new (gtk_gl_area_get_type); gl_area^.glcontext := glcontext; //writeln('gtk_gl_area_share_new E ',gl_area<>nil); + DebugLn(['gtk_gl_area_share_new BBB3']); {$IFNDEF MSWindows} - // pop back defaults - gtk_widget_pop_visual; - gtk_widget_pop_colormap; + if visual<>nil then begin + // pop back defaults + gtk_widget_pop_visual; + gtk_widget_pop_colormap; + end; {$ENDIF non MSWindows} Result:=PGtkWidget(gl_area); end; @@ -641,7 +674,9 @@ begin if not GTK_IS_GL_AREA(glarea) then exit; if not GTK_WIDGET_REALIZED(PGtkWidget(glarea)) then exit; + DebugLn(['gtk_gl_area_make_current START']); Result:=gdk_gl_make_current(PGtkWidget(glarea)^.window, glarea^.glcontext); + DebugLn(['gtk_gl_area_make_current END']); end; function gtk_gl_area_begingl(glarea: PGtkGLArea): boolean; diff --git a/components/opengl/openglcontext.pas b/components/opengl/openglcontext.pas index f9d643a7bb..7482081e7a 100644 --- a/components/opengl/openglcontext.pas +++ b/components/opengl/openglcontext.pas @@ -53,7 +53,7 @@ uses GLGtkGlxContext; {$ENDIF} {$IFDEF UseGtk2GLX} - GLGtk2GlxContext; + GLGtkGlxContext; {$ENDIF} {$IFDEF UseCarbonAGL} GLCarbonAGLContext; diff --git a/components/prettymessages/README.txt b/components/prettymessages/README.txt new file mode 100644 index 0000000000..6efbfc8442 --- /dev/null +++ b/components/prettymessages/README.txt @@ -0,0 +1,7 @@ +prettymessages +============== + +This package is an Lazarus IDE add on, which helps to reduce FPC hints, notes +and warnings. If you want to hide a specific hint, click right on a message +and in the popup menu click on Hide FPC hint. + diff --git a/components/prettymessages/hidefpchints.pas b/components/prettymessages/hidefpchints.pas new file mode 100644 index 0000000000..361f0b4739 --- /dev/null +++ b/components/prettymessages/hidefpchints.pas @@ -0,0 +1,203 @@ +{ Extends Lazarus to hide FPC messages. + For example: + testunit1.pas(20,27) Hint: Parameter "X" not used + + + Copyright (C) 2007 Mattias Gaertner mattias@freepascal.org + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU Library General Public License as published by + the Free Software Foundation; either version 2 of the License, or (at your + option) any later version with the following modification: + + As a special exception, the copyright holders of this library give you + permission to link this library with independent modules to produce an + executable, regardless of the license terms of these independent modules,and + to copy and distribute the resulting executable under terms of your choice, + provided that you also meet, for each linked independent module, the terms + and conditions of the license of that module. An independent module is a + module which is not derived from or based on this library. If you modify + this library, you may extend this exception to your version of the library, + but you are not obligated to do so. If you do not wish to do so, delete this + exception statement from your version. + + 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. See the GNU Library General Public License + for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +} +unit HideFPCHints; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, SysUtils, LCLProc, Controls, + // IDEIntf + IDEMsgIntf, LazIDEIntf, SrcEditorIntf, + // CodeTools + BasicCodeTools, SourceLog, CodeCache, CodeToolManager, + // our stuff + PrettyMsgOptions; + +type + + { THideFPCHintWorker } + + THideFPCHintWorker = class(TIDEMsgQuickFixItem) + public + constructor Create; + destructor Destroy; override; + procedure Execute(const Msg: TIDEMessageLine; Step: TIMQuickFixStep); override; + function IsApplicable(Line: TIDEMessageLine): boolean; override; + end; + +procedure QuickFixHideFPCHint(Sender: TObject; Step: TIMQuickFixStep; + Msg: TIDEMessageLine); + +procedure Register; + +implementation + +procedure QuickFixHideFPCHint(Sender: TObject; Step: TIMQuickFixStep; + Msg: TIDEMessageLine); +begin + +end; + +procedure Register; +var + Item: TIDEMsgQuickFixItem; +begin + Item:=THideFPCHintWorker.Create; + RegisterIDEMsgQuickFix(Item); +end; + +{ THideFPCHintWorker } + +constructor THideFPCHintWorker.Create; +begin + inherited Create; + Name:='Hide FPC hints'; + Caption:='Hide this FPC hint'; + Steps:=[imqfoImproveMessage,imqfoMenuItem]; +end; + +destructor THideFPCHintWorker.Destroy; +begin + inherited Destroy; +end; + +procedure THideFPCHintWorker.Execute(const Msg: TIDEMessageLine; + Step: TIMQuickFixStep); +var + Filename: string; + Line: integer; + Column: integer; + CodeBuf: TCodeBuffer; + LineRange: TLineRange; + DirectivePos: LongInt; + Src: String; + EndPos: LongInt; + p: LongInt; + MsgType: string; + Directive: String; + SrcEdit: TSourceEditorInterface; + InsertPos: Integer; + HasDirective: Boolean; +begin + inherited Execute(Msg, Step); + + // get filename and line number and load file + if Msg.Parts=nil then exit; + if Msg.Parts.Values['Stage']<>'FPC' then exit; + MsgType:=Msg.Parts.Values['Type']; + if MsgType='Hint' then + Directive:='h-' + else if MsgType='Note' then + Directive:='n-' + else if MsgType='Warning' then + Directive:='w-' + else + exit; + + Msg.GetSourcePosition(Filename,Line,Column); + //DebugLn(['THideFPCHintWorker.Execute ',Filename,' Line=',Line]); + CodeBuf:=CodeToolBoss.LoadFile(Filename,false,false); + if CodeBuf=nil then exit; + if (Line<1) or (Line>CodeBuf.LineCount) then exit; + Src:=CodeBuf.Source; + CodeBuf.GetLineRange(Line-1,LineRange); + + // check if the code contains an IDE directive to hide the hint + HasDirective:=false; + p:=LineRange.StartPos; + EndPos:=LineRange.EndPos; + repeat + DirectivePos:=FindNextIDEDirective(Src,p,true,EndPos); + if (DirectivePos<1) then break; + if CompareSubStrings(Directive,Src,1,DirectivePos+2,2,false)=0 then begin + //DebugLn(['THideFPCHintWorker.Execute Ignoring message: ',Msg.Msg]); + HasDirective:=true; + end; + p:=DirectivePos; + while (p'}') do inc(p); + until p>=EndPos; + + if Step=imqfoMenuItem then begin + // user clicked on the menu item to add an IDE directive + if HasDirective then exit; + + // open the file in the source editor + if LazarusIDE.DoOpenFileAndJumpToPos(Filename,Point(1,Line),-1,-1, + [ofOnlyIfExists,ofRegularFile,ofUseCache,ofDoNotLoadResource])<>mrOk then + begin + DebugLn(['THideFPCHintWorker.Execute open failed: ',Filename]); + exit; + end; + // find the source editor page + SrcEdit:=SourceEditorWindow.SourceEditorIntfWithFilename(Filename); + if SrcEdit=nil then begin + DebugLn(['THideFPCHintWorker.Execute unable to find the file in the source editor of ',Filename]); + exit; + end; + // find the source editor line + if SrcEdit.LineCount hide the message + if HasDirective then + Msg.Visible:=false; + end; +end; + +function THideFPCHintWorker.IsApplicable(Line: TIDEMessageLine): boolean; +var + MsgType: string; +begin + Result:=false; + if Line.Parts=nil then exit; + if Line.Parts.Values['Stage']<>'FPC' then exit; + MsgType:=Line.Parts.Values['Type']; + if MsgType='Hint' then + Result:=true + else if MsgType='Note' then + Result:=true + else if MsgType='Warning' then + Result:=true; +end; + +end. + diff --git a/components/prettymessages/prettymessages.lpk b/components/prettymessages/prettymessages.lpk new file mode 100644 index 0000000000..8cf2892d7a --- /dev/null +++ b/components/prettymessages/prettymessages.lpk @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/components/prettymessages/prettymessages.pas b/components/prettymessages/prettymessages.pas new file mode 100644 index 0000000000..70c84bef40 --- /dev/null +++ b/components/prettymessages/prettymessages.pas @@ -0,0 +1,21 @@ +{ This file was automatically created by Lazarus. Do not edit! +This source is only used to compile and install the package. + } + +unit PrettyMessages; + +interface + +uses + HideFPCHints, PrettyMsgOptionsDlg, PrettyMsgOptions, LazarusPackageIntf; + +implementation + +procedure Register; +begin + RegisterUnit('HideFPCHints', @HideFPCHints.Register); +end; + +initialization + RegisterPackage('PrettyMessages', @Register); +end. diff --git a/components/prettymessages/prettymsgoptions.pas b/components/prettymessages/prettymsgoptions.pas new file mode 100644 index 0000000000..7e00c278e0 --- /dev/null +++ b/components/prettymessages/prettymsgoptions.pas @@ -0,0 +1,49 @@ +{ Options for the pretty message package. + + + Copyright (C) 2007 Mattias Gaertner mattias@freepascal.org + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU Library General Public License as published by + the Free Software Foundation; either version 2 of the License, or (at your + option) any later version with the following modification: + + As a special exception, the copyright holders of this library give you + permission to link this library with independent modules to produce an + executable, regardless of the license terms of these independent modules,and + to copy and distribute the resulting executable under terms of your choice, + provided that you also meet, for each linked independent module, the terms + and conditions of the license of that module. An independent module is a + module which is not derived from or based on this library. If you modify + this library, you may extend this exception to your version of the library, + but you are not obligated to do so. If you do not wish to do so, delete this + exception statement from your version. + + 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. See the GNU Library General Public License + for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +} +unit PrettyMsgOptions; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, SysUtils; + +type + TPrettyMsgOptions = class + public + + end; + +implementation + +end. + diff --git a/components/prettymessages/prettymsgoptionsdlg.lfm b/components/prettymessages/prettymsgoptionsdlg.lfm new file mode 100644 index 0000000000..52d8b02f77 --- /dev/null +++ b/components/prettymessages/prettymsgoptionsdlg.lfm @@ -0,0 +1,30 @@ +object PrettyMsgOptionsDialog: TPrettyMsgOptionsDialog + Left = 294 + Height = 300 + Top = 164 + Width = 400 + HorzScrollBar.Page = 399 + VertScrollBar.Page = 299 + Caption = 'PrettyMsgOptionsDialog' + OnCreate = FormCreate + Position = poScreenCenter + object OkButton: TButton + Left = 192 + Height = 25 + Top = 264 + Width = 75 + BorderSpacing.InnerBorder = 4 + Caption = 'OkButton' + TabOrder = 0 + end + object CancelButton: TButton + Left = 288 + Height = 25 + Top = 264 + Width = 75 + BorderSpacing.InnerBorder = 4 + Caption = 'CancelButton' + ModalResult = 2 + TabOrder = 1 + end +end diff --git a/components/prettymessages/prettymsgoptionsdlg.lrs b/components/prettymessages/prettymsgoptionsdlg.lrs new file mode 100644 index 0000000000..736e546e07 --- /dev/null +++ b/components/prettymessages/prettymsgoptionsdlg.lrs @@ -0,0 +1,13 @@ +{ This is an automatically generated lazarus resource file } + +LazarusResources.Add('TPrettyMsgOptionsDialog','FORMDATA',[ + 'TPF0'#23'TPrettyMsgOptionsDialog'#22'PrettyMsgOptionsDialog'#4'Left'#3'&'#1#6 + +'Height'#3','#1#3'Top'#3#164#0#5'Width'#3#144#1#18'HorzScrollBar.Page'#3#143 + +#1#18'VertScrollBar.Page'#3'+'#1#7'Caption'#6#22'PrettyMsgOptionsDialog'#8'O' + +'nCreate'#7#10'FormCreate'#8'Position'#7#14'poScreenCenter'#0#7'TButton'#8'O' + +'kButton'#4'Left'#3#192#0#6'Height'#2#25#3'Top'#3#8#1#5'Width'#2'K'#25'Borde' + +'rSpacing.InnerBorder'#2#4#7'Caption'#6#8'OkButton'#8'TabOrder'#2#0#0#0#7'TB' + +'utton'#12'CancelButton'#4'Left'#3' '#1#6'Height'#2#25#3'Top'#3#8#1#5'Width' + +#2'K'#25'BorderSpacing.InnerBorder'#2#4#7'Caption'#6#12'CancelButton'#11'Mod' + +'alResult'#2#2#8'TabOrder'#2#1#0#0#0 +]); diff --git a/components/prettymessages/prettymsgoptionsdlg.pas b/components/prettymessages/prettymsgoptionsdlg.pas new file mode 100644 index 0000000000..6d0977417e --- /dev/null +++ b/components/prettymessages/prettymsgoptionsdlg.pas @@ -0,0 +1,74 @@ +{ Extends Lazarus with a dialog to edit the options of the pretty message + package. + + + Copyright (C) 2007 Mattias Gaertner mattias@freepascal.org + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU Library General Public License as published by + the Free Software Foundation; either version 2 of the License, or (at your + option) any later version with the following modification: + + As a special exception, the copyright holders of this library give you + permission to link this library with independent modules to produce an + executable, regardless of the license terms of these independent modules,and + to copy and distribute the resulting executable under terms of your choice, + provided that you also meet, for each linked independent module, the terms + and conditions of the license of that module. An independent module is a + module which is not derived from or based on this library. If you modify + this library, you may extend this exception to your version of the library, + but you are not obligated to do so. If you do not wish to do so, delete this + exception statement from your version. + + 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. See the GNU Library General Public License + for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +} +unit PrettyMsgOptionsDlg; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, Buttons; + +type + + { TPrettyMsgOptionsDialog } + + TPrettyMsgOptionsDialog = class(TForm) + OkButton: TButton; + CancelButton: TButton; + procedure FormCreate(Sender: TObject); + private + { private declarations } + public + { public declarations } + end; + +var + PrettyMsgOptionsDialog: TPrettyMsgOptionsDialog; + +implementation + +{ TPrettyMsgOptionsDialog } + +procedure TPrettyMsgOptionsDialog.FormCreate(Sender: TObject); +begin + Caption:='Options of Pretty Messages'; + + OkButton.Caption:='Ok'; + CancelButton.Caption:='Cancel'; +end; + +initialization + {$I prettymsgoptionsdlg.lrs} + +end. + diff --git a/ide/msgview.pp b/ide/msgview.pp index 63d8e160d7..3b7363ce38 100644 --- a/ide/msgview.pp +++ b/ide/msgview.pp @@ -133,6 +133,7 @@ type FirstLine, LineCount: Integer); procedure UpdateMsgLineInListBox(Line: TLazMessageLine); function ExecuteMsgLinePlugin(Step: TIMQuickFixStep): boolean; + procedure HideLine(Line: TLazMessageLine); procedure ConsistencyCheck; public property LastLineIsProgress: boolean read FLastLineIsProgress @@ -436,6 +437,7 @@ procedure TMessagesView.CollectLineParts(Sender: TObject; QuickFixItem: TIDEMsgQuickFixItem; j: Integer; OldMsg: String; + OldVisible: Boolean; begin for i:=StartIndex to FItems.Count-1 do begin ALine:=Items[i]; @@ -444,10 +446,17 @@ procedure TMessagesView.CollectLineParts(Sender: TObject; if (imqfoImproveMessage in QuickFixItem.Steps) and QuickFixItem.IsApplicable(ALine) then begin OldMsg:=ALine.Msg; + OldVisible:=ALine.VisiblePosition>=0; + ALine.Visible:=OldVisible; QuickFixItem.Execute(ALine,imqfoImproveMessage); UpdateMsgSrcPos(ALine); - if OldMsg<>ALine.Msg then + if (OldVisible<>ALine.Visible) then begin + if not ALine.Visible then + HideLine(ALine); + end; + if (OldMsg<>ALine.Msg) then begin UpdateMsgLineInListBox(ALine); + end; end; end; end; @@ -562,8 +571,9 @@ begin Line.VisiblePosition := FVisibleItems.Count; FVisibleItems.Add(Line); end - else + else begin Line.VisiblePosition := -1; + end; end; // rebuild MessageTreeView.Items MessageTreeView.BeginUpdate; @@ -671,6 +681,34 @@ begin end; end; +procedure TMessagesView.HideLine(Line: TLazMessageLine); +var + i: Integer; + OldIndex: LongInt; +begin + OldIndex:=Line.VisiblePosition; + if OldIndex<0 then exit; + //DebugLn(['TMessagesView.HideLine ',OldIndex]); + if (OldIndex>=0) and (OldIndex=0) + and (OldIndex