//================================================================================= // Required changes in the User Interface file to add // own ViewFinds buffer for each edited file (The tse.ui file as an example). // // Used a special View Finds Buffers History. // When TSE loaded this History is being created. // When each file opened - ViewFinds buffer is created and added string to // View Finds Buffers History, which contains current edited file buffer ID and // his View Finds buffer ID. // When file closed - its View Finds Buffer and string in // View Finds Buffers History are deleted. // When the TSE is terminated - View Finds Buffers History are deleted. // // Every time another file is switched to - also switched View Finds Buffer. // //================================================================================= integer vfb_hist // Viewfindsbuffer_histoty //================================================================================= // This macro is called on editor startup //================================================================================= proc WhenLoaded() // SetWindowTitle(TSEPro_title) // LoadStartupMacros() // set_startup_window_size() // if Query(TemplateExpansion) // mLoadTemplate() // endif // // Add History Lists // vfb_hist = GetFreeHistory("UI:vfb") // Create ViewFindsBuffer_histoty // Hook the events we want to get control of // Hook(_ON_FIRST_EDIT_, OnFirstEdit) // Hook(_ON_CHANGING_FILES_, OnChangingFiles) // Hook(_PROMPT_STARTUP_, OnPromptStartup) // Hook(_ON_SELFINSERT_, OnSelfInsert) // Hook(_ON_DELCHAR_, OnDelChar) // Hook(_ON_FILE_QUIT_, OnFileQuit) // if isGUI() // SetFileApisToANSI() // endif // // See if input is redirected, if so, read it in as a file // handle_input_redirection() // process_command_line() // end // //================================================================================= // This macro is called the first time a file is loaded into the editor. // This is a hooked macro //================================================================================= proc OnFirstEdit() // integer curr_id = GetBufferId() // ID of current file buffer integer found_id = 0 // ID of ViewFinds Buffer case CurrExt() // when ".c", // ".cpp", ".cc", ".cxx", ".h", ".hpp", // ".cs", // ".java" // SetBufferStr(UI_COMPRESSVIEW, "function-list-c -list") // SetBufferStr(UI_NEXTPARA, "function-list-c -nextpara") // SetBufferStr(UI_PREVPARA, "function-list-c -prevpara") // when ".sql" // SetBufferStr(UI_COMPRESSVIEW, "function-list-sql -list") // SetBufferStr(UI_NEXTPARA, "function-list-sql -nextpara") // SetBufferStr(UI_PREVPARA, "function-list-sql -prevpara") // endcase // PushPosition() // Create ViewFinds buffer found_id = CreateTempBuffer() // EmptyBuffer(found_id) // Set(ViewFindsId, found_id) // AddHistoryStr(Str(curr_id)+","+Str(found_id), vfb_hist) // Add ViewFinds Buffer History String PopPosition() // end // //================================================================================= // This macro is called everytime EditFile() or Next/PrevFile() is called. // This is a hooked macro. //================================================================================= proc SwitchViewFind() // Switch View Finds Buffer integer strnum // for strnum = 1 to NumHistoryItems(vfb_hist) // if (GetToken(GetHistoryStr(vfb_hist, strnum), ",", 1) == Str(GetBufferID())) // Set(ViewFindsId, Val(GetToken(GetHistoryStr(vfb_hist, strnum), ",", 2))) // break // endif // endfor // end // //================================================================================= // This macro is called everytime EditFile() or Next/PrevFile() is called. // This is a hooked macro. //================================================================================= proc OnChangingFiles() // // For 'RecentFiles' processing, only show files that are displayed // Hook(_AFTER_UPDATE_DISPLAY_, AFterUpdateDisplay) // language = FALSE // cmode = FALSE // sal = FALSE // case CurrExt() // when ".ui", ".s", ".si", ".inc" // language = TRUE // sal = TRUE // when ".c", ".h", ".cpp", ".cc", ".cxx", ".hpp", ".cs", ".java" // language = TRUE // cmode = TRUE // when ".asm", ".pas", ".pp", ".dpr", ".prg", ".bas", ".vbs", ".pl", ".py" // language = TRUE // endcase // SwitchViewFind() // Switch View Finds Buffer end // //================================================================================= // This macro is called just before the editor quits a file // This is a hooked macro //================================================================================= proc OnFileQuit() // integer strnum // for strnum = 1 to NumHistoryItems(vfb_hist) // if (GetToken(GetHistoryStr(vfb_hist, strnum), ",", 1) == Str(GetBufferID())) // AbandonFile(Val(GetToken(GetHistoryStr(vfb_hist, strnum), ",", 2))) // Delete Buffer ??? DelHistoryStr(vfb_hist, strnum) // Delete ViewFinds Buffer History String break // endif // endfor // end // //================================================================================= // This macro is called just before the _ON_ABANDON_EDITOR_ hook is called. //================================================================================= proc WhenPurged() // PushPosition() // if Query(PersistentRecentFiles) and GotoBufferId(recent_files) and NumLines() // cleanup_recent_files_list(20) // merge_recent_lists(RecentFilesStr()) // SaveAs(RecentFilesStr(), _OVERWRITE_ | _DONT_PROMPT_) // endif // PopPosition() // DelHistory(vfb_hist) // Delete ViewFindsBuffer_histoty end //