From abe8a2602b0be141b5db46f4de3ea154cb272e96 Mon Sep 17 00:00:00 2001 From: mcmlxxix <> Date: Fri, 15 Feb 2013 22:00:00 +0000 Subject: [PATCH] added word_wrap toggle to Frame() objects (default off), set word_wrap on for chat views in Layout() objects --- exec/load/frame.js | 23 ++++++++++++++++++----- exec/load/layout.js | 3 ++- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/exec/load/frame.js b/exec/load/frame.js index 5d055fcf58..e1166e6039 100644 --- a/exec/load/frame.js +++ b/exec/load/frame.js @@ -133,24 +133,25 @@ function Frame(x,y,width,height,attr,parent) { open:false, ctrl_a:false, id:0 - } + }; var settings = { v_scroll:true, h_scroll:false, scrollbars:false, lf_strict:true, checkbounds:true, - transparent:false - } + transparent:false, + word_wrap:false + }; var relations = { parent:undefined, child:[] - } + }; var position = { cursor:new Cursor(0,0,this), offset:new Offset(0,0,this), stored:new Cursor(0,0,this) - } + }; /* protected properties */ this.__defineGetter__("child", function() { @@ -290,6 +291,15 @@ function Frame(x,y,width,height,attr,parent) { else throw("non-boolean v_scroll: " + bool); }); + this.__defineGetter__("word_wrap", function() { + return settings.word_wrap; + }); + this.__defineSetter__("word_wrap", function(bool) { + if(typeof bool == "boolean") + settings.word_wrap=bool; + else + throw("non-boolean word_wrap: " + bool); + }); this.__defineGetter__("h_scroll", function() { return settings.h_scroll; }); @@ -322,6 +332,7 @@ function Frame(x,y,width,height,attr,parent) { px += position.offset.x; py += position.offset.y; } + //I don't remember why I did this, but it was probably important at the time //if(!properties.data[py] || !properties.data[py][px]) if(!properties.data[py]) throw("Frame.setData() - invalid coordinates: " + px + "," + py); @@ -831,6 +842,8 @@ function Frame(x,y,width,height,attr,parent) { this.putmsg = function(str,attr) { if(str == undefined) return; + if(settings.word_wrap) + str = word_wrap(str,this.width); str = str.toString().split(''); var curattr = attr; if(!curattr) diff --git a/exec/load/layout.js b/exec/load/layout.js index 161e818af3..3c4f093f18 100644 --- a/exec/load/layout.js +++ b/exec/load/layout.js @@ -533,6 +533,7 @@ function LayoutView(title,frame,parent) { } properties.chat = tab.chat; tab.frame.lf_strict = false; + tab.frame.word_wrap = true; tab.hotkeys = false; break; case "FRAME": @@ -692,7 +693,7 @@ function LayoutView(title,frame,parent) { /* view tab object, meant to inhabit a layout view. * will generally occupy the same space as other view tabs * within a given view, cannot be effectively instantiated - * on its own, but rather through ViewFrame.addTab() */ + * on its own, but rather through LayoutView.addTab() */ function ViewTab(title,frame,parent) { /* private properties */ var properties={ -- GitLab