Re: Contact menu's width patch (was Re: CVS access or Project Progress)

Stephen <z35_11-/[email protected]> Sat, 17 Feb 2007 09:04:42 -0800 (PST)
Newsgroups gmane.network.centericq
Message-ID <[email protected]>
>On Fri, Feb 16, 2007 at 06:03:48PM -0800, Stephen wrote:
>> 
>> If using the patch, don't forget to add the correct lines to the
>> keybindings file

> Did you also add a default binding in the source when someone DOES
> forget to add them to the file?

There is no such completed section. If the user deletes:

bind contact q quit

from keybindings, then the user will not be able to exit the program... There is a section that looks like it was started to handle this, however, AFAIK, It is no where near complete. It is in icqconf.cc line~ 400ish. 


Also, I was playing around with the it a little bit, and found a bug the prohibits a user from chatting due to the chat resize, fixed it and allowed a user to disable that function by setting the chat panel height to zero. 





 
____________________________________________________________________________________
We won't tell. Get more on shows you hate to love 
(and love to hate): Yahoo! TV's Guilty Pleasures list.
http://tv.yahoo.com/collections/265

_______________________________________________
Cicq mailing list
Cicq-xGejAJT2w6wWP6gT/[email protected]
http://mailman.linuxpl.org/mailman/listinfo/cicq
Questions? Check the FAQ first: http://centericq.de/faq/
cicq-panel_sizing-20070217a.patch (application/octet-stream, 12.1 KB)
diff -u centerim/src/icqconf.cc centerim.mod/src/icqconf.cc
--- centerim/src/icqconf.cc	2007-02-16 22:03:40.000000000 -0500
+++ centerim.mod/src/icqconf.cc	2007-02-16 20:04:00.000000000 -0500
@@ -248,6 +248,10 @@
 	    of << "bind contact\t/\tquickfind" << endl << endl;
 	    of << "bind contact\t\\cn\tnext_chat" << endl;
 	    of << "bind contact\t\\cb\tprev_chat" << endl;
+	    of << "bind contact\t[\tleft_panel_move_left" << endl;
+	    of << "bind contact\t]\tleft_panel_move_right" << endl;
+	    of << "bind contact\t{\tlog_panel_move_up" << endl;
+	    of << "bind contact\t}\tlog_panel_move_down" << endl;
 	    of << "bind history\t/\tsearch" << endl;
 	    of << "bind history\ts\tsearch" << endl;
 	    of << "bind history\tn\tsearch_again" << endl;
@@ -262,6 +266,8 @@
 	    of << "bind editor\t\\a?\tinfo" << endl;
 	    of << "bind editor\t<F2>\tshow_urls" << endl;
 	    of << "bind editor\t<F9>\tfullscreen" << endl << endl;
+	    of << "bind editor\t<F4>\tchat_panel_move_up" << endl;
+	    of << "bind editor\t<F5>\tchat_panel_move_down" << endl;
 	    of << "bind info\t<F2>\tshow_urls" << endl;
 	    of << "bind info\t<F6>\tuser_external_action" << endl;
 
@@ -377,8 +383,14 @@
 	    if(param == "show_urls") k.action = key_show_urls; else
 	    if(param == "rss_check") k.action = key_rss_check; else
 	    if(param == "multiple_recipients") k.action = key_multiple_recipients; else
-	    if(param == "user_external_action") k.action = key_user_external_action;
-		else continue;
+	    if(param == "user_external_action") k.action = key_user_external_action; else
+	    if(param == "left_panel_move_left")  k.action = key_left_panel_move_left; else
+	    if(param == "left_panel_move_right") k.action = key_left_panel_move_right; else
+	    if(param == "log_panel_move_up")    k.action = key_log_panel_move_up; else
+	    if(param == "log_panel_move_down")  k.action = key_log_panel_move_down; else
+	    if(param == "chat_panel_move_up")  k.action = key_chat_panel_move_up; else
+	    if(param == "chat_panel_move_down")  k.action = key_chat_panel_move_down; else
+		    continue;
 
 	    keys.push_back(k);
 	}
@@ -475,6 +487,9 @@
 	    if(param == "fromcharset") fromcharset = buf; else
 	    if(param == "tocharset") tocharset = buf; else
 	    if(param == "timestampstothesecond") settimestampstothesecond(true); else
+	    if(param == "left_panel_width")  leftpanelwidth  = atol(buf.c_str()); else
+	    if(param == "log_panel_height") logpanelheight = atol(buf.c_str()); else
+	    if(param == "chat_panel_height") chatpanelheight = atol(buf.c_str()); else
 	    if(param == "ptp") {
 		ptpmin = atoi(getword(buf, "-").c_str());
 		ptpmax = atoi(buf.c_str());
@@ -591,6 +606,10 @@
 	    if(getmakelog()) f << "log" << endl;
 	    if(getproxyconnect()) f << "proxy_connect" << endl;
 	    if(getproxyssl()) f << "proxy_ssl" << endl;
+	    
+	    if(getleftpanelwidth())  f << "left_panel_width\t"  << getleftpanelwidth()  << endl;
+	    if(getlogpanelheight()) f << "log_panel_height\t" << getlogpanelheight() << endl;
+	    if(getchatpanelheight()) f << "chat_panel_height\t" << getchatpanelheight() << endl;
 
 	    vector<imaccount>::iterator ia;
 	    for(ia = accounts.begin(); ia != accounts.end(); ++ia)
diff -u centerim/src/icqconf.h centerim.mod/src/icqconf.h
--- centerim/src/icqconf.h	2007-02-16 22:03:40.000000000 -0500
+++ centerim.mod/src/icqconf.h	2007-02-16 20:04:00.000000000 -0500
@@ -85,7 +85,13 @@
     key_show_urls,
     key_rss_check,
     key_multiple_recipients,
-    key_user_external_action
+    key_user_external_action,
+    key_left_panel_move_right,
+    key_left_panel_move_left,
+    key_log_panel_move_up,
+    key_log_panel_move_down,
+    key_chat_panel_move_up,
+    key_chat_panel_move_down
 };
 
 class icqconf {
@@ -162,6 +168,9 @@
 	regcolor rc;
 	groupmode fgroupmode;
 	colormode cm;
+	int leftpanelwidth;
+	int logpanelheight;
+	int chatpanelheight;
 
 	colorschemer<cicq_colorpairs> schemer;
 
@@ -325,6 +334,13 @@
 
 	bool getxtitles() const { return !notitles; }
 	bool getdebug() const { return debug; }
+	
+	int  getleftpanelwidth() const { return leftpanelwidth; }
+	void setleftpanelwidth(const int width)   { leftpanelwidth  = width; }
+	int  getlogpanelheight() const { return logpanelheight; }
+	void setlogpanelheight(const int height) { logpanelheight = height; }
+	int  getchatpanelheight() const { return chatpanelheight; }
+	void setchatpanelheight(const int height) { chatpanelheight = height; }
 };
 
 extern icqconf conf;
diff -u centerim/src/icqdialogs.cc centerim.mod/src/icqdialogs.cc
--- centerim/src/icqdialogs.cc	2007-02-16 22:03:40.000000000 -0500
+++ centerim.mod/src/icqdialogs.cc	2007-02-16 20:04:00.000000000 -0500
@@ -1087,6 +1087,7 @@
 bool icqface::updateconf(icqconf::regsound &s, icqconf::regcolor &c) {
     bool finished, success, hasany;
     int nopt, n, i, b, nconf, ncomm, aaway, ana, noth, nfeat, ncl;
+    bool needredraw = false;
     protocolname pname;
     string tmp, phidden;
 
@@ -1179,6 +1180,9 @@
 	i = t.addnode(_(" User interface "));
 	t.addleaff(i, 0, 1, _(" Change sound device to : %s "), strregsound(s));
 	t.addleaff(i, 0, 2, _(" Change color scheme to : %s "), strregcolor(c));
+	t.addleaff(i, 0, 51, _(" Left panel width :  %d "), conf.getleftpanelwidth());
+	t.addleaff(i, 0, 52, _(" Log panel height :  %d "), conf.getlogpanelheight());
+	t.addleaff(i, 0, 53, _(" Chat panel height : %d "), conf.getchatpanelheight());
 
     #ifdef USE_FRIBIDI
 	t.addleaff(i, 0, 20, _( " Enable bidirectional languages support : %s "), stryesno(bidi));
@@ -1386,6 +1390,22 @@
 		        break;
  		    case 48:
 		        timestampstothesecond = !timestampstothesecond; break;
+		    case 51:
+			    conf.setleftpanelwidth(atol(inputstr(_("Left panel width: "), 
+    			strint(conf.getleftpanelwidth())).c_str()));
+	    		needredraw = true;
+		    	break;
+		    case 52:
+    			conf.setlogpanelheight(atol(inputstr(_("Log panel height: "), 
+	    		strint(conf.getlogpanelheight())).c_str()));
+		    	needredraw = true;
+			    break;
+		    case 53:
+    			conf.setchatpanelheight(atol(inputstr(_("Chat panel height: "), 
+	    		strint(conf.getchatpanelheight())).c_str()));
+		    	needredraw = true;
+		        break;
+
   		}
   		break;
 	    case 1:
@@ -1435,6 +1455,9 @@
     db.close();
     unblockmainscreen();
 
+    if(needredraw)
+	    icqface::redraw();
+
     return success;
 }
 
diff -u centerim/src/icqface.cc centerim.mod/src/icqface.cc
--- centerim/src/icqface.cc	2007-02-16 22:03:40.000000000 -0500
+++ centerim.mod/src/icqface.cc	2007-02-16 22:56:14.000000000 -0500
@@ -153,16 +153,26 @@
     sizeBigDlg.width = COLS-10;
     sizeBigDlg.height = LINES-7;
 
-    sizeWArea.x1 = (int) (COLS*0.32);
-    if(sizeWArea.x1 < 25)
-	sizeWArea.x1 = 25;
-
-    sizeWArea.x2 = COLS-1;
-    sizeWArea.y1 = 1;
-
-    sizeWArea.y2 = LINES - ((int) (LINES/4));
-    if(sizeWArea.y2 > LINES-6)
-	sizeWArea.y2 = LINES-6;
+	sizeWArea.x1 = conf.getleftpanelwidth();
+	if(sizeWArea.x1 > ((int) (COLS * 0.66))) {
+		sizeWArea.x1 = (int) (COLS * 0.66); 
+		conf.setleftpanelwidth(sizeWArea.x1);}
+	if(sizeWArea.x1 < 10) {
+		sizeWArea.x1 = 10;
+		conf.setleftpanelwidth(sizeWArea.x1);}
+	
+	sizeWArea.x2 = COLS-1;
+	sizeWArea.y1 = 1;
+
+	sizeWArea.y2 = conf.getlogpanelheight();
+	if(sizeWArea.y2 < 2){
+		sizeWArea.y2 = 2 ;
+		conf.setlogpanelheight(sizeWArea.y2);}
+	if(sizeWArea.y2 > LINES - 12) {
+		sizeWArea.y2 = LINES - 12;
+		conf.setlogpanelheight(sizeWArea.y2);}
+
+	sizeWArea.y2 = LINES - sizeWArea.y2;
 
     if(!mcontacts) {
 	mcontacts = new treeview(conf.getcolor(cp_main_menu),
@@ -2686,6 +2696,7 @@
     texteditor editor;
     imevent *sendev;
     vector<imcontact>::iterator i;
+    int chatline_diff = 0;
 
     icqcontact *c = clist.get(ic);
     if(!c) return;
@@ -2701,7 +2712,20 @@
     muins.clear();
     muins.push_back(passinfo);
 
-    chatlines = (int) ((sizeWArea.y2-sizeWArea.y1)*0.75);
+    chatline_diff = sizeWArea.y2 - sizeWArea.y1 ; 
+    chatlines = conf.getchatpanelheight();
+    if( chatlines == 0 ) {
+        chatlines = (int) (chatline_diff*0.75);
+    } else {
+        chatlines = chatline_diff - chatlines;
+        if( chatlines < (chatline_diff*0.10)) {
+            chatlines = (int) (chatline_diff*0.10);
+            conf.setchatpanelheight(chatline_diff - chatlines);}
+        if( chatlines > (chatline_diff*0.90)) {
+            chatlines = (int) (chatline_diff*0.90);
+            conf.setchatpanelheight(chatline_diff - chatlines);}
+    }
+
 //    workarealine(sizeWArea.y1+chatlines+1);
 
     editor.addscheme(cp_main_text, cp_main_text, 0, 0);
@@ -3074,37 +3098,14 @@
 // ----------------------------------------------------------------------------
 
 void icqface::menuidle(verticalmenu &m) {
-    cicq.idle();
-
-    if(face.dotermresize) {
-	if(&m == &face.mcontacts->menu) {
-	    face.done();
-	    face.init();
-	    face.draw();
-
-	    /*
-	     * Terminal resize specific
-	     */
-
-	    vector<string> flog;
-	    vector<string>::iterator il;
+	cicq.idle();
 
-	    face.status("#");
-
-	    flog = face.lastlog;
-	    face.lastlog.clear();
-
-	    bool lts, lo;
-	    conf.getlogoptions(lts, lo);
-	    conf.setlogoptions(false, lo);
-
-	    for(il = flog.begin(); il != flog.end(); ++il)
-		face.log(*il);
-
-	    conf.setlogoptions(lts, lo);
-	    face.dotermresize = false;
+	if(face.dotermresize) {
+		if(&m == &face.mcontacts->menu) {
+			face.redraw();
+			face.dotermresize = false;
+		}
 	}
-    }
 }
 
 void icqface::dialogidle(dialogbox &caller) {
@@ -3336,6 +3337,26 @@
 	    if(c) face.extk = ACT_IGNORE;
 	    break;
 
+        case key_left_panel_move_right:
+            face.leftpanelwidth_inc(1);
+            face.redraw();
+            break;
+ 
+        case key_left_panel_move_left:
+            face.leftpanelwidth_inc(-1);
+            face.redraw();
+            break;
+
+        case key_log_panel_move_up:
+            face.logpanelheight_inc(1);
+            face.redraw();
+            break;
+	   
+        case key_log_panel_move_down:
+            face.logpanelheight_inc(-1);
+            face.redraw();
+            break;
+
 	case key_quickfind: face.extk = ACT_QUICKFIND; break;
     }
 
@@ -3439,6 +3460,12 @@
 	    if(face.passevent)
 		face.fullscreenize(face.passevent);
 	    break;
+        case key_chat_panel_move_up:
+            face.chatpanelheight_inc(1);
+            break;
+        case key_chat_panel_move_down:
+            face.chatpanelheight_inc(-1);
+            break;
 	case key_quit:
 	    return -1;
     }
@@ -3526,14 +3553,36 @@
 }
 
 void icqface::redraw() {
-    if(!mainscreenblock) {
-	done();
-	init();
-	draw();
-	doredraw = fneedupdate = false;
-    } else {
-	doredraw = fneedupdate = true;
-    }
+	if(!mainscreenblock) {
+		done();
+		init();
+		draw();
+
+		/*
+		 * Terminal resize specific
+		 */
+
+		vector<string> flog;
+		vector<string>::iterator il;
+
+		face.status("#");
+
+		flog = face.lastlog;
+		face.lastlog.clear();
+
+		bool lts, lo;
+		conf.getlogoptions(lts, lo);
+		conf.setlogoptions(false, lo);
+
+		for(il = flog.begin() ; il != flog.end(); ++il)
+			face.log(*il);
+
+		conf.setlogoptions(lts, lo);
+
+		doredraw = fneedupdate = false;
+	} else {
+		doredraw = fneedupdate = true;
+	}
 }
 
 void icqface::xtermtitle(const string &text) {
@@ -3606,3 +3655,19 @@
 void icqface::icqprogress::hide() {
     w->close();
 }
+
+void icqface::leftpanelwidth_inc(const int inc) {
+	conf.setleftpanelwidth(conf.getleftpanelwidth()+inc);
+}
+
+void icqface::logpanelheight_inc(const int inc) {
+	conf.setlogpanelheight(conf.getlogpanelheight()+inc);
+}
+
+void icqface::chatpanelheight_inc(const int inc ) {
+	conf.setchatpanelheight(conf.getchatpanelheight()+inc);
+	// This does not work to well, you will have to leave, and re-enter
+	icqface::restoreworkarea();
+	icqface::renderchathistory();
+}
+
diff -u centerim/src/icqface.h centerim.mod/src/icqface.h
--- centerim/src/icqface.h	2007-02-16 22:03:40.000000000 -0500
+++ centerim.mod/src/icqface.h	2007-02-16 20:04:01.000000000 -0500
@@ -286,6 +286,9 @@
 	void userinfoexternal(const imcontact &ic);
 
 	bool selectpgpkey(string &keyid, bool secretonly = false);
+	void leftpanelwidth_inc(const int inc);
+	void logpanelheight_inc(const int inc);
+	void chatpanelheight_inc(const int inc);
 };
 
 extern icqface face;