aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authormathias <mathias>2004-12-24 03:02:48 (GMT)
committermathias <mathias>2004-12-24 03:02:48 (GMT)
commit1910d5af463ebc9e49cb53a14377f557288c6139 (patch)
tree31643f8c9a360f01a1cc74e7ddf36f3584dbeab5 /util
parentd39897f19dbbb728971e1320621b3ef911ef4c85 (diff)
downloadfluxbox_paul-1910d5af463ebc9e49cb53a14377f557288c6139.zip
fluxbox_paul-1910d5af463ebc9e49cb53a14377f557288c6139.tar.bz2
fix the no-writing-history issue for fbrun
Diffstat (limited to 'util')
-rw-r--r--util/fbrun/FbRun.cc31
1 files changed, 19 insertions, 12 deletions
diff --git a/util/fbrun/FbRun.cc b/util/fbrun/FbRun.cc
index 4b51c4b..da3ee6b 100644
--- a/util/fbrun/FbRun.cc
+++ b/util/fbrun/FbRun.cc
@@ -140,20 +140,27 @@ void FbRun::run(const std::string &command) {
140 } 140 }
141 } 141 }
142 142
143 // now m_current_history_item points at the duplicate, or
144 // at m_history.size() if no duplicate
145 fstream inoutfile(m_history_file.c_str(), ios::in|ios::out); 143 fstream inoutfile(m_history_file.c_str(), ios::in|ios::out);
146 if (inoutfile) { 144 if (inoutfile) {
147 int i = 0; 145 // now m_current_history_item points at the duplicate, or
148 // read past history items before current 146 // at m_history.size() if no duplicate
149 for (string line; !inoutfile.eof() && i < m_current_history_item; i++) 147 if (m_current_history_item != m_history.size()) {
150 getline(inoutfile, line); 148 int i = 0;
151 // write the history items that come after current 149 // read past history items before current
152 for (i++; i < m_history.size(); i++) 150 for (; inoutfile.good() && i < m_current_history_item; i++)
153 inoutfile<<m_history[i]<<endl; 151 inoutfile.ignore(1, '\n');
154 152
155 // and append the current one back to the end 153 // write the history items that come after current
156 inoutfile<<text()<<endl; 154 for (i++; i < m_history.size(); i++)
155 inoutfile<<m_history[i]<<endl;
156
157 } else {
158 // set put-pointer at end of file
159 inoutfile.seekp(0, ios::end);
160 }
161 // append current command to the file
162 inoutfile<<command<<endl;
163
157 } else 164 } else
158 cerr<<"FbRun Warning: Can't write command history to file: "<<m_history_file<<endl; 165 cerr<<"FbRun Warning: Can't write command history to file: "<<m_history_file<<endl;
159 } 166 }