Archive
Quartex pascal, foundation stone laid
Managed to get a couple of hours work done on QPAS (quartex pascal) today, and finally I have reached the part where all the different sub-systems come together. Writing an IDE is not the same as writing a notepad clone or simple text editor. The concept of project item types (for instance, how do you define a unit versus a textfile? Should a file ending with .res open up in a text-editor or a hex-dump?), storage mechanisms, source templates, search paths – the list goes on. Point is, it has to be abstract enough to be flexible, but rigid enough to take a punch and provide logical structure.
Today I got the time to glue the project-element templates (unit, program unit etc.) into the actual creation of a unit. I also got rid of all the initial hardcoded stuff. So when QPAS starts-up it reads all the information from files. Adding a new project type with different sub-elements (php, C#, javascript etc) is more or less a matter of writing some .inifiles which defines what the editor should do, provide a default source template (optional), and voila — the IDE has no clue about the difference between a unit and a textfile is, but it will handle both differently based on definitions now user-adaptable.
So in short: Yes, the IDE can be adapted for other languages (finally we can put those synEdit syntax highlighters to good use)!
But those are just the default “low level IDE stuff”, I will also need to add support for pre-defined projects. You know when you create a new delphi project, it basically just copies an already existing project from disk? This will be the next part.
Application services
In order to make this scriptable I had to add some overhead. First, everything is neatly isolated in a core class which provides access to all the sub-systems. It was very tempting to just litter the code with functions (like “getTemplateList”) rather than coding full manager classes, but I’m in no hurry – and I have a full daytime job besides. So I decided to take my time.
Here is an example from the IDE:
function TfrmMainForm.getBufferForUnit(aIdentifier:String; var aData:String):Boolean; var mOpen:TObjectList; x: Integer; mExt: String; mName: String; mFound: TQTFileSourceRefList; mText: TStringlist; mData: TStream; mRef: String; mAccess: TIDEAccessManager; begin (* Initialize to negative *) result:=False; mOpen:=NIL; setLength(aData,0); (* Make sure we can do this *) if not (csDestroying in ComponentState) and not (csLoading in ComponentState) and not application.Terminated then begin (* Request access to IDE API *) if getIDEAccess(mAccess) then begin mExt:=ExtractFileExt(aIdentifier); (* Get buffer from open tab *) if getOpenTabsForProject(mAccess.ProjectManager.ActiveProject,mOpen) then begin try for x:=0 to mOpen.Count-1 do begin (* NOTE: replace with byterage->compare later! *) if SameText(mopen[x].Item.Identifier,aIdentifier) then begin if (mOpen[x].Frame is TframePascal) then begin aData:=TframePascal(mOpen[x].Frame).editor.Text; break; end; end; end; result:=length(aData)>0; finally mOpen.Free; end; end; if not result then begin if length(mExt)=0 then mName:=aIdentifier + '.pas' else mName:=aIdentifier; if mAccess.FileSourceManager.LocateFileByName(mName,mFound) then begin try if mFound.Count>0 then begin mtext:=TStringlist.Create; try (* Get unit candidates, sort by priority to the project *) mRef:=mAccess.FileSourceManager.SortByPriority(mFound,mAccess.ProjectManager.ActiveProject).Items[0]; WriteMessageF('using package unit [%s]',[mRef]); try if mAccess.FileSourceManager.ObtainStreamFromRef(mRef,mData) then begin try (* Note: Replace with streamToStr before alpha *) mtext.LoadFromStream(mData); aData:=mtext.Text; result:=true; finally mData.Free; end; end; except on e: exception do TIDEExceptionHandler.HandleIOException(e,ehLogMessage); end; finally mtext.Free; end; end; finally mFound.Free; end; end; end; end; end; end;
Now to get rid of the “.pas” harcoded string (query the project.template subsystem) and rename the editor frame to something more useful. Or just go bananaz and compile with packages and isolate different editors in DLL plugins (ala eclipse).
Recent
The vatican vault
- January 2022
- October 2021
- March 2021
- November 2020
- September 2020
- July 2020
- June 2020
- April 2020
- March 2020
- February 2020
- January 2020
- November 2019
- October 2019
- September 2019
- August 2019
- July 2019
- June 2019
- May 2019
- April 2019
- March 2019
- February 2019
- January 2019
- December 2018
- November 2018
- October 2018
- September 2018
- August 2018
- July 2018
- June 2018
- May 2018
- April 2018
- March 2018
- February 2018
- January 2018
- December 2017
- November 2017
- October 2017
- August 2017
- July 2017
- June 2017
- May 2017
- April 2017
- March 2017
- February 2017
- January 2017
- December 2016
- November 2016
- October 2016
- September 2016
- August 2016
- July 2016
- June 2016
- May 2016
- April 2016
- March 2016
- January 2016
- December 2015
- November 2015
- October 2015
- September 2015
- August 2015
- June 2015
- May 2015
- April 2015
- March 2015
- February 2015
- January 2015
- December 2014
- November 2014
- October 2014
- September 2014
- August 2014
- July 2014
- June 2014
- May 2014
- April 2014
- March 2014
- February 2014
- January 2014
- December 2013
- November 2013
- October 2013
- September 2013
- August 2013
- July 2013
- June 2013
- May 2013
- February 2013
- August 2012
- June 2012
- May 2012
- April 2012
You must be logged in to post a comment.