#ifndef IDE_H #define IDE_H #include #include #include #include #include #include #include #include #include #include #define LAYOUTFILE #include #define IMAGECLASS IdeImg #define IMAGEFILE #include #define KEYGROUPNAME "Ide" #define KEYNAMESPACE IdeKeys #define KEYFILE #include #include "version.h" #include #include #ifdef PLATFORM_POSIX #include #endif const char *FindTag(const char *txt, const char *tag); const char *FindAfter(const char *txt, const char *tag); int IdeLocateLine(String old_file, int old_line, String new_file); #include "UppDlg.h" bool IsTextFile(const String& file); void Puts(const char *s); class Console : public LineEdit { public: virtual bool Key(dword key, int count); virtual void LeftDouble(Point p, dword); virtual void RightDown(Point p, dword); virtual void Append(const String& s); protected: struct Slot { Slot() : outfile(NULL), quiet(true), exitcode(Null) {} One process; String cmdline; String output; String key; String group; Stream *outfile; bool quiet; int exitcode; int last_msecs; }; struct Group { Group() : count(0), start_time(::msecs()), finished(false), msecs(0), raw_msecs(0) {} int count; int start_time; bool finished; int msecs; int raw_msecs; }; Array processes; ArrayMap groups; Vector error_keys; String current_group; String spooled_output; int console_lock; bool wrap_text; FrameBottom input; String line; void CheckEndGroup(); void FlushConsole(); public: Callback WhenSelect; Callback1 WhenBar; Callback1 WhenLine; Callback WhenRunEnd; bool console; bool verbosebuild; int Execute(const char *cmdline, Stream *out = NULL, const char *envptr = NULL, bool quiet = false, bool noconvert = false); int Execute(One pick_ process, const char *cmdline, Stream *out = NULL, bool quiet = false); int GetSlotCount() const { return processes.GetCount(); } int AllocSlot(); bool Run(const char *cmdline, Stream *out = NULL, const char *endptr = NULL, bool quiet = false, int slot = 0, String key = Null, int blitz_count = 1); bool Run(One pick_ process, const char *cmdline, Stream *out = NULL, bool quiet = false, int slot = 0, String key = Null, int blitz_count = 1); void BeginGroup(String group); void EndGroup(); Console& operator<<(const String& s) { Append(s); return *this; } void ToErrors(const String& s); void AppendOutput(const String& s); bool IsRunning(); bool IsRunning(int slot); int Flush(); void Kill(int slot); void Kill(); void ClearError() { error_keys.Clear(); line.Clear(); WhenRunEnd(); } Vector PickErrors() { Vector e = pick(error_keys); error_keys.Clear(); return pick(e); } void Wait(int slot); bool Wait(); void WrapText(bool w) { wrap_text = w; } void SetSlots(int s); void Input(bool b); Console(); }; VectorMap& BuilderMap(); String SelectAnyPackage(); String FindInDirs(const Vector& dir, const String& file); String FindCommand(const Vector& exedir, const String& cmdline); void DlCharset(DropList& d); void DlCharsetD(DropList& d); void SetupBuildMethods(); VectorMap GetMethodVars(const String& method); String GetDefaultMethod(); bool CheckLicense(); bool Install(); #define HELPNAME "Help Topics" #define METAPACKAGE "" class TopicCtrl : public HelpWindow { public: virtual Topic AcquireTopic(const String& topic); virtual void BarEx(Bar& bar); virtual bool Key(dword key, int count); virtual void FinishText(RichText& text); private: EditString search; DropList lang; bool internal; bool showwords, all; VectorMap > > map; Index lang_list; Vector spos; static Index idelink; void OpenTopic(); void Search(); void ShowWords(); void All(); void Lang(); void SShow(); void ScanDirForTpp(const char *dir, const String& rel, Index& donepackage, Index& lang_list); void LoadMap(); void FocusSearch(); void Prev(); void Next(); public: Callback WhenTopic; void SyncDocTree(); void SearchWord(const String& s); void Serialize(Stream& s); typedef TopicCtrl CLASSNAME; TopicCtrl(); }; struct IdeCalc : CodeEditor { virtual bool Key(dword key, int count); virtual void LeftDouble(Point p, dword flags); ArrayMap vars; void Execute(); IdeCalc(); }; void AutoSetup(); extern bool splash_screen; void HideSplash(); void ShowSplash(); bool IsSplashOpen(); class RightTabs : public FrameCtrl { public: virtual void Paint(Draw& w); virtual void LeftDown(Point p, dword); virtual void MouseMove(Point p, dword); virtual void MouseLeave(); virtual void CancelMode(); virtual void FramePaint(Draw& w, const Rect& r); virtual void FrameLayout(Rect& r); virtual void FrameAddSize(Size& sz); private: enum { SPACE = 7 }; struct Tab { int y; Image img; String tip; int GetHeight() const { return img.GetSize().cy + SPACE; } int GetRight() const { return y + GetHeight(); } }; Array tab; int cx; int hl; int cursor; void Repos(); void PaintTab(Draw& w, int x, int y, int cx, int cy, Color paper, const Image& img, Color hl); int GetPos(Point p); public: void Clear(); void Add(const Image& img, const String& tip); void SetCursor(int i); int GetCursor() const { return cursor; } RightTabs(); }; class EditorTabBar : public FileTabs { public: EditorTabBar(); String GetFile(int n) const; bool FindSetFile(const String& fn); void SetAddFile(const String& fn); void RenameFile(const String& fn, const String& nn); void SetSplitColor(const String& fn, const Color& c); void ClearSplitColor(); typedef EditorTabBar CLASSNAME; }; int memcmp_i(const char *s, const char *t, int n); String ParseTemplatedType(const String& type, Vector& tparam); String ResolveTParam(const String& type, const Vector& tparam); void ResolveTParam(Vector& type, const Vector& tparam); String Qualify(const String& scope, const String& type); int CharFilterMacro(int c); int CharFilterFileName(int c); bool isincludefnchar(int c); Size GetDrawFileNameSize(const String& h); void DrawFileName(Draw& w, const Rect& r, const String& h, Color ink); struct Navigator { virtual int GetCurrentLine() = 0; struct NavLine : Moveable { bool impl:1; int file:31; int line; bool operator<(const NavLine& b) const; }; struct NavItem { String nest; String qitem; String name; String uname; String natural; String type; String pname; String ptype; String tname; String ctname; byte access; byte kind; int16 at; int line; int file; bool impl; int decl_line; // header position int decl_file; bool decl; Vector linefo; void Set(const CppItem& m); }; enum KindEnum { KIND_LINE = 123, KIND_NEST, KIND_FILE }; struct ScopeDisplay : Display { int DoPaint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const; virtual void Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const; virtual Size GetStdSize(const Value& q) const; }; struct LineDisplay : Display { int DoPaint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style, int x) const; virtual void Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const; virtual Size GetStdSize(const Value& q) const; }; struct NavigatorDisplay : Display { const Vector& item; int DoPaint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const; virtual void PaintBackground(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const; virtual void Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const; virtual Size GetStdSize(const Value& q) const; NavigatorDisplay(const Vector& item) : item(item) {} }; Ide *theide; Array nitem; VectorMap > gitem; Vector litem; Array nest_item; VectorMap > linefo; NavigatorDisplay navidisplay; bool navigating; TimeCallback search_trigger; bool navigator_global; ToolButton sortitems; bool sorting; bool dlgmode; ArrayCtrl scope; ArrayCtrl list; ArrayCtrl navlines; EditString search; void TriggerSearch(); void NavGroup(bool local); void Search(); void Scope(); void ListLineEnabled(int i, bool& b); void NaviSort(); Vector GetNavLines(const NavItem& m); void Navigate(); void NavigatorClick(); void NavigatorEnter(); void SyncLines(); void SyncNavLines(); void GoToNavLine(); void SyncCursor(); static bool SortByLines(const NavItem *a, const NavItem *b); static bool SortByNames(const NavItem *a, const NavItem *b); typedef Navigator CLASSNAME; Navigator(); }; struct AssistEditor : CodeEditor, Navigator { virtual bool Key(dword key, int count); virtual void LostFocus(); virtual void MouseWheel(Point p, int zdelta, dword keyflags); virtual void LeftDown(Point p, dword keyflags); virtual void SelectionChanged(); virtual void DirtyFrom(int line); virtual void State(int reason); virtual int GetCurrentLine(); struct IndexItem : Moveable { String text; Color ink; int line; }; bool navigator; SplitterFrame navigatorframe; StaticRect navigatorpane; Splitter navigator_splitter; Splitter popup; ArrayCtrl assist; ArrayCtrl type; Index assist_type; ArrayMap assist_item; RichTextCtrl annotation_popup; int assist_cursor; bool auto_assist; bool assist_active; bool commentdp; bool inbody; bool thisback, thisbackn; bool include_assist; WString cachedline; int cachedpos; int cachedln; bool include_local; int include_back; String include_path; int scan_counter; RichTextCtrl param_info; String param_qtf; struct ParamInfo { int line; int pos; WString test; CppItem item; String editfile; ParamInfo() { line = -1; } }; enum { PARAMN = 16 }; ParamInfo param[PARAMN]; int parami; void PopUpAssist(bool auto_insert = false); void CloseAssist(); void Assist(); bool IncludeAssist(); String ReadIdBackPos(int& pos, bool include); String ReadIdBack(int q, bool include = false); void SyncAssist(); void AssistInsert(); bool InCode(); void SyncParamInfo(); void StartParamInfo(const CppItem& m, int pos); Vector GetFileIds(); void Complete(); void Complete2(); void Abbr(); void Context(Parser& parser, int pos); void ExpressionType(const String& type, const Vector& xp, int ii, Index& typeset, bool variable, bool can_shortcut_operator, Index& visited_bases, int lvl); void ExpressionType(const String& type, const Vector& xp, int ii, Index& typeset, bool variable, int lvl); // void ExpressionType(const String& type, const Vector& xp, int ii, // Index& typeset); Index ExpressionType(const Parser& parser, const Vector& xp); Index EvaluateExpressionType(const Parser& parser, const Vector& xp); String RemoveDefPar(const char *s); String MakeDefinition(const String& cls, const String& _n); void DCopy(); void Virtuals(); void Thisbacks(); void GatherItems(const String& type, bool only_public, Index& in_types, bool types); void SelParam(); int Ch(int q); int ParsBack(int q); Vector ReadBack(int q); void SkipSpcBack(int& q); String IdBack(int& qq); String CompleteIdBack(int& q); void SwapSContext(Parser& p); bool GetAnnotationRefs(Vector& tl, String& coderef, int q = -1); bool GetAnnotationRef(String& t, String& coderef, int q = -1); void SyncAnnotationPopup(); void EditAnnotation(bool fastedit); void Annotate(const String& filename); void OpenTopic(String topic, String create, bool before); void NewTopic(String group, String coderef); bool Esc(); bool IsNavigator() const { return navigator; } void Navigator(bool navigator); void SyncNavigator(); void SerializeNavigator(Stream& s); Callback1 WhenFontScroll; typedef AssistEditor CLASSNAME; AssistEditor(); }; void DirSel(EditField& f, FrameRight