Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # HG changeset patch
- # User Jerome LAFORGE <jerome.laforge@gmail.com>
- # Date 1317127561 -7200
- # Branch AddSessionFindWhat
- # Node ID 60d66825e5f271c5143b6f7ff1ca6e1eccc40a72
- # Parent 4708e0216ca160da0786fa822fbe343e51ebca4b
- Add save.find to save "Find what" and "Replace with" into session.
- diff -r 4708e0216ca1 -r 60d66825e5f2 doc/SciTEDoc.html
- --- a/doc/SciTEDoc.html dim. sept. 25 09:58:27 2011 +1000
- +++ b/doc/SciTEDoc.html mar. sept. 27 14:46:01 2011 +0200
- @@ -2315,7 +2315,8 @@
- <td>
- save.session<br />
- save.recent<br />
- - save.position
- + save.position<br />
- + save.find
- </td>
- <td>
- If you set save.session, the list of currently opened buffers will be saved on exit
- @@ -2331,7 +2332,9 @@
- Setting save.recent causes the most recently used files list to be saved on
- exit in the session file and read at start up.<br />
- Setting save.position causes the SciTE window position on the desktop to be
- - saved on exit in the session file and restored at start up.
- + saved on exit in the session file and restored at start up.<br />
- + Setting save.find cause the "Find what" and "Replace with" to be saved on
- + exit in the session file and read at start up.
- </td>
- </tr>
- <tr>
- diff -r 4708e0216ca1 -r 60d66825e5f2 src/SciTEBase.cxx
- --- a/src/SciTEBase.cxx dim. sept. 25 09:58:27 2011 +1000
- +++ b/src/SciTEBase.cxx mar. sept. 27 14:46:01 2011 +0200
- @@ -4518,6 +4518,8 @@
- bool SciTEBase::ProcessCommandLine(GUI::gui_string &args, int phase) {
- bool performPrint = false;
- bool evaluate = phase == 0;
- + if (evaluate && props.GetInt("save.find") != 0)
- + RestoreFindWhat();
- std::vector<GUI::gui_string> wlArgs = ListFromString(args);
- // Convert args to vector
- for (size_t i = 0; i < wlArgs.size(); i++) {
- diff -r 4708e0216ca1 -r 60d66825e5f2 src/SciTEBase.h
- --- a/src/SciTEBase.h dim. sept. 25 09:58:27 2011 +1000
- +++ b/src/SciTEBase.h mar. sept. 27 14:46:01 2011 +0200
- @@ -518,6 +518,7 @@
- void LoadSessionFile(const GUI::gui_char *sessionName);
- void RestoreRecentMenu();
- void RestoreSession();
- + void RestoreFindWhat();
- void SaveSessionFile(const GUI::gui_char *sessionName);
- virtual void GetWindowPosition(int *left, int *top, int *width, int *height, int *maximize) = 0;
- void SetIndentSettings();
- diff -r 4708e0216ca1 -r 60d66825e5f2 src/SciTEBuffers.cxx
- --- a/src/SciTEBuffers.cxx dim. sept. 25 09:58:27 2011 +1000
- +++ b/src/SciTEBuffers.cxx mar. sept. 27 14:46:01 2011 +0200
- @@ -463,6 +463,24 @@
- SetDocumentAt(curr);
- }
- +void SciTEBase::RestoreFindWhat() {
- + for (int i = 0; true; i++) {
- + SString propKey = IndexPropKey("search", i, "findWhat");
- + SString propStr = propsSession.Get(propKey.c_str());
- + if (propStr == "")
- + break;
- + memFinds.AppendList(propStr.c_str());
- + }
- +
- + for (int i = 0; true; i++) {
- + SString propKey = IndexPropKey("search", i, "replaceWith");
- + SString propStr = propsSession.Get(propKey.c_str());
- + if (propStr == "")
- + break;
- + memReplaces.AppendList(propStr.c_str());
- + }
- +}
- +
- void SciTEBase::SaveSessionFile(const GUI::gui_char *sessionName) {
- bool defaultSession;
- FilePath sessionPathName;
- @@ -506,6 +524,31 @@
- }
- }
- + if (defaultSession && props.GetInt("save.find")) {
- + SString propKey;
- + std::vector<std::string>::iterator it;
- + std::vector<std::string> mem = memFinds.AsVector();
- + if (!mem.empty()) {
- + fprintf(sessionFile, "\n");
- + it = mem.begin();
- + for (int i = 0; it != mem.end(); i++, it++) {
- + propKey = IndexPropKey("search", i, "findWhat");
- + fprintf(sessionFile, "%s=%s\n", propKey.c_str(), (*it).c_str());
- + }
- + }
- +
- + mem = memReplaces.AsVector();
- + if (!mem.empty()) {
- + fprintf(sessionFile, "\n");
- + mem = memReplaces.AsVector();
- + it = mem.begin();
- + for (int i = 0; it != mem.end(); i++, it++) {
- + propKey = IndexPropKey("search", i, "replaceWith");
- + fprintf(sessionFile, "%s=%s\n", propKey.c_str(), (*it).c_str());
- + }
- + }
- + }
- +
- if (props.GetInt("buffers") && (!defaultSession || props.GetInt("save.session"))) {
- int curr = buffers.Current();
- for (int i = 0; i < buffers.length; i++) {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement