summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Remember.cc36
-rw-r--r--src/Remember.hh13
2 files changed, 21 insertions, 28 deletions
diff --git a/src/Remember.cc b/src/Remember.cc
index 99ba0b4..d4af300 100644
--- a/src/Remember.cc
+++ b/src/Remember.cc
@@ -20,7 +20,7 @@
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21// DEALINGS IN THE SOFTWARE. 21// DEALINGS IN THE SOFTWARE.
22 22
23// $Id: Remember.cc,v 1.1 2003/04/26 07:57:00 rathnor Exp $ 23// $Id: Remember.cc,v 1.2 2003/04/26 11:24:55 rathnor Exp $
24 24
25#include "Remember.hh" 25#include "Remember.hh"
26#include "StringUtil.hh" 26#include "StringUtil.hh"
@@ -40,12 +40,8 @@
40#include <iostream> 40#include <iostream>
41#include <sstream> 41#include <sstream>
42#include <fstream> 42#include <fstream>
43/* 43#include <string>
44 #include <string> 44#include <memory>
45 #include <memory>
46 #include <stdio.h>
47*/
48
49 45
50#ifndef MAXPATHLEN 46#ifndef MAXPATHLEN
51#define MAXPATHLEN 255 47#define MAXPATHLEN 255
@@ -196,8 +192,8 @@ Application* Remember::find(const char* app_name) {
196 return NULL; 192 return NULL;
197} 193}
198 194
199int Remember::parseApp(ifstream &file, Application *a) { 195int Remember::parseApp(std::ifstream &file, Application *a) {
200 string line; 196 std::string line;
201 int row = 0; 197 int row = 0;
202 while (! file.eof()) { 198 while (! file.eof()) {
203 if (getline(file, line)) { 199 if (getline(file, line)) {
@@ -218,17 +214,17 @@ int Remember::parseApp(ifstream &file, Application *a) {
218 continue; //read next line 214 continue; //read next line
219 if (str_key == "Workspace") { 215 if (str_key == "Workspace") {
220 unsigned int w; 216 unsigned int w;
221 istringstream iss(str_label.c_str()); 217 std::istringstream iss(str_label.c_str());
222 iss >> w; 218 iss >> w;
223 a->rememberWorkspace(w); 219 a->rememberWorkspace(w);
224 } else if (str_key == "Dimensions") { 220 } else if (str_key == "Dimensions") {
225 unsigned int h,w; 221 unsigned int h,w;
226 istringstream iss(str_label.c_str()); 222 std::istringstream iss(str_label.c_str());
227 iss >> w >> h; 223 iss >> w >> h;
228 a->rememberDimensions(w,h); 224 a->rememberDimensions(w,h);
229 } else if (str_key == "Position") { 225 } else if (str_key == "Position") {
230 unsigned int x,y; 226 unsigned int x,y;
231 istringstream iss(str_label); 227 std::istringstream iss(str_label);
232 iss >> x >> y; 228 iss >> x >> y;
233 a->rememberPosition(x,y); 229 a->rememberPosition(x,y);
234 } else if (str_key == "Shaded") { 230 } else if (str_key == "Shaded") {
@@ -255,7 +251,7 @@ int Remember::parseApp(ifstream &file, Application *a) {
255 unsigned int mask; 251 unsigned int mask;
256 const char * str = str_label.c_str(); 252 const char * str = str_label.c_str();
257 // it'll have at least one char and \0, so this is safe 253 // it'll have at least one char and \0, so this is safe
258 istringstream iss(str); 254 std::istringstream iss(str);
259 // check for hex 255 // check for hex
260 if (str[0] == '0' && str[1] == 'x') { 256 if (str[0] == '0' && str[1] == 'x') {
261 iss.seekg(2); 257 iss.seekg(2);
@@ -285,23 +281,23 @@ void Remember::load() {
285#ifdef DEBUG 281#ifdef DEBUG
286 cerr << "Loading apps file..." << endl; 282 cerr << "Loading apps file..." << endl;
287#endif // DEBUG 283#endif // DEBUG
288 string apps_string = getenv("HOME")+string("/.")+RC_PATH+string("/")+"apps"; 284 std::string apps_string = getenv("HOME")+std::string("/.")+RC_PATH+std::string("/")+"apps";
289 ifstream apps_file(apps_string.c_str()); 285 std::ifstream apps_file(apps_string.c_str());
290 if (!apps_file.fail()) { 286 if (!apps_file.fail()) {
291 if (!apps_file.eof()) { 287 if (!apps_file.eof()) {
292 string line; 288 std::string line;
293 int row = 0; 289 int row = 0;
294 while (getline(apps_file, line) && ! apps_file.eof()) { 290 while (getline(apps_file, line) && ! apps_file.eof()) {
295 row++; 291 row++;
296 if (line[0] == '#') 292 if (line[0] == '#')
297 continue; 293 continue;
298 string key; 294 std::string key;
299 int pos=0; 295 int pos=0;
300 int err = StringUtil::getStringBetween(key, line.c_str(), '[', ']'); 296 int err = StringUtil::getStringBetween(key, line.c_str(), '[', ']');
301 297
302 if (err >0 && key == "app") { 298 if (err >0 && key == "app") {
303 pos += err; 299 pos += err;
304 string label; 300 std::string label;
305 err = StringUtil::getStringBetween(label, line.c_str()+pos, '(', ')'); 301 err = StringUtil::getStringBetween(label, line.c_str()+pos, '(', ')');
306 if (err>0) { 302 if (err>0) {
307 Application *a; 303 Application *a;
@@ -332,8 +328,8 @@ void Remember::save() {
332#ifdef DEBUG 328#ifdef DEBUG
333 cerr << "Saving apps file..." << endl; 329 cerr << "Saving apps file..." << endl;
334#endif // DEBUG 330#endif // DEBUG
335 string apps_string = getenv("HOME")+string("/.")+RC_PATH+string("/")+"apps"; 331 std::string apps_string = getenv("HOME")+std::string("/.")+RC_PATH+std::string("/")+"apps";
336 ofstream apps_file(apps_string.c_str()); 332 std::ofstream apps_file(apps_string.c_str());
337 Apps::iterator it = apps.begin(); 333 Apps::iterator it = apps.begin();
338 Apps::iterator it_end = apps.end(); 334 Apps::iterator it_end = apps.end();
339 for (; it != it_end; ++it) { 335 for (; it != it_end; ++it) {
diff --git a/src/Remember.hh b/src/Remember.hh
index bc7b292..dc632cc 100644
--- a/src/Remember.hh
+++ b/src/Remember.hh
@@ -20,7 +20,7 @@
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21// DEALINGS IN THE SOFTWARE. 21// DEALINGS IN THE SOFTWARE.
22 22
23// $Id: Remember.hh,v 1.1 2003/04/26 07:57:00 rathnor Exp $ 23// $Id: Remember.hh,v 1.2 2003/04/26 11:24:55 rathnor Exp $
24 24
25/* Based on the original "Remember patch" by Xavier Brouckaert */ 25/* Based on the original "Remember patch" by Xavier Brouckaert */
26 26
@@ -30,14 +30,11 @@
30#include "Window.hh" 30#include "Window.hh"
31#include "AtomHandler.hh" 31#include "AtomHandler.hh"
32#include "Screen.hh" 32#include "Screen.hh"
33
34/*
35#include <iostream>
36#include <string>
37#include "StringUtil.hh" 33#include "StringUtil.hh"
38*/ 34
39#include <fstream> 35#include <fstream>
40#include <map> 36#include <map>
37#include <string>
41 38
42class Application { 39class Application {
43public: 40public:
@@ -123,7 +120,7 @@ public:
123 REM_LASTATTRIB // not actually used 120 REM_LASTATTRIB // not actually used
124 }; 121 };
125 122
126 typedef std::map<string,Application *> Apps; 123 typedef std::map<std::string,Application *> Apps;
127 Remember(); 124 Remember();
128 125
129 Application* find(WinClient &winclient); 126 Application* find(WinClient &winclient);
@@ -166,7 +163,7 @@ public:
166private: 163private:
167 164
168 // returns number of lines read 165 // returns number of lines read
169 int parseApp(ifstream &file, Application *a); 166 int parseApp(std::ifstream &file, Application *a);
170 Apps apps; 167 Apps apps;
171 168
172}; 169};