Closed Bug 307774 Opened 19 years ago Closed 18 years ago

when pasting a new line, the multi-line input should be activated automatically

Categories

(Other Applications :: ChatZilla, enhancement)

enhancement
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: tunnie, Assigned: rdmsoft)

Details

(Whiteboard: [cz-0.9.73])

Attachments

(1 file, 1 obsolete file)

5.12 KB, patch
bugzilla-mozilla-20000923
: review+
Details | Diff | Splinter Review
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.7.10) Gecko/20050717 Firefox/1.0.6
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.7.10) Gecko/20050717 Firefox/1.0.6

This would save a little bit of time when inserting multi-line text into a
conversation. I'm undecided as to whether the box should return to single-line
state after the message has been sent, and also whether Enter should send the
message instead of making another new line on these auto-multi-line occasions.

Reproducible: Always

Steps to Reproduce:
1. Copy some multi-line text (with "\n" in) from any source.
2. Paste into single-line ChatZilla input box

Actual Results:  
ChatZilla only inserts the first line of the copied text.

Expected Results:  
Automatically switch to multi-line input and paste the entire text.
Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Windows XP → All
Hardware: PC → All
Assignee: rginda → rdmsoft
Status: NEW → ASSIGNED
Attached patch initial version (obsolete) — Splinter Review
This doesn't do either of the possible extras from comment 0, but it does strip leading and trailing newlines to fit the text in the single-line box if it can.

I'm not sure how familiar users in general are with the multiline box, and whether popping it up automatically will confuse. Needs discussion, I think.
Attachment #214205 - Flags: review?(silver)
Comment on attachment 214205 [details] [diff] [review]
initial version

>+    var str = new Object();
>+    var strlen = new Object();
>+    data.getTransferData("text/unicode", str, strlen);
>+    str.value.QueryInterface(Components.interfaces.nsISupportsString);
>+    str.value.data = str.value.data.replace(/(^\s*[\r\n]+|[\r\n]+\s*$)/g, "");
>+
>+    if (str.value.data.indexOf("\n") == -1)
>+    {
>+        // If, after stripping leading/trailing empty lines, the string is a
>+        // single line, put it back in the transferable and return.
>+        data.setTransferData("text/unicode", str.value, str.value.data.length);

This is wrong - the length should be 2 times the JS length. Look at some of the code surrounding the items here:
  http://lxr.mozilla.org/mozilla/search?string=setTransferData%28%2522text%2Funicode

>+        return true;
>+    }
>+
>+    // Drop in the right position...
>+    if (e && ("rangeOffset" in e))
>+        client.input.setSelectionRange(e.rangeOffset, e.rangeOffset);
>+
>+    str = client.input.value.substr(0, client.input.selectionStart) +
>+          str.value.data + client.input.value.substr(client.input.selectionEnd);

Could really do with a comment longer than "Drop in the right position" - you're positioning the selection (based on something that is completely unexplained), then inserting the text where the selection is.

>+    client.prefs["multiline"] = true;
>+    client.input.value = str;
>+    return false;


>+function doCommandWithParams(command, params)
>+{
>+    try {
>+        var dispatcher = top.document.commandDispatcher;

Is |top| really required there? |top === window| in all ChatZilla's code.

>+        var controller = dispatcher.getControllerForCommand(command);
>+        controller.QueryInterface(Components.interfaces.nsICommandController);
>+        var cmdparams = newObject("@mozilla.org/embedcomp/command-params;1",
>+                                  "nsICommandParams");
>+        for (var i in params)
>+            cmdparams.setISupportsValue(i, params[i]);
>+
>+        if (controller && controller.isCommandEnabled(command))
>+            controller.doCommandWithParams(command, cmdparams);

Perhaps should bail out if !controller || !controller.isCommandEnabled before you bother with the params object.
Attachment #214205 - Flags: review?(silver) → review-
Attached patch take twoSplinter Review
Attachment #214205 - Attachment is obsolete: true
Attachment #214338 - Flags: review?(silver)
Attachment #214338 - Flags: review?(silver) → review+
Checked in --> FIXED.
Status: ASSIGNED → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
Whiteboard: [cz-0.9.73]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: