On Fri, Oct 14, 2016 at 04:38:31PM -0400, Scott Kostyshak wrote:

> > The second solution would be to use
> > 
> > lyx_name = cmd.getArg(0);
> > x11_name = cmd.getArg(1);
> > 
> > In this case, the syntax for set-color would be
> > set-color foo bar
> > set-color "foo bar" baz
> > set-color foo "bar baz"
> > ...
> > 
> > I really prefer this second solution. And any of these is better than
> > relying on split and rtrim.
> 
> Makes sense. I'll work on a better patch.

Is the attached what you meant? If so I would audit the other calls to
LFUN_SET_COLOR.

Scott
From 8ee7da3c15ca2ac8db338f9e8ba438b17a9029e3 Mon Sep 17 00:00:00 2001
From: Scott Kostyshak <skost...@lyx.org>
Date: Thu, 20 Oct 2016 22:41:31 -0400
Subject: [PATCH] Fix color when branch name has a space

TODO: fix other calls to LFUN_SET_COLOR
---
 src/Buffer.cpp                       | 3 ++-
 src/frontends/qt4/GuiApplication.cpp | 6 +++---
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index 2dcdefe..5502eca 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -2716,7 +2716,8 @@ void Buffer::dispatch(FuncRequest const & func, 
DispatchResult & dr)
                                branch_list.add(branch_name);
                                branch = branch_list.find(branch_name);
                                string const x11hexname = 
X11hexname(branch->color());
-                               docstring const str = branch_name + ' ' + 
from_ascii(x11hexname);
+                               docstring const str = '"' + branch_name + '"' + 
' ' +
+                                                     '"' + 
from_ascii(x11hexname) + '"';
                                lyx::dispatch(FuncRequest(LFUN_SET_COLOR, str));
                                dr.setError(false);
                                dr.screenUpdate(Update::Force);
diff --git a/src/frontends/qt4/GuiApplication.cpp 
b/src/frontends/qt4/GuiApplication.cpp
index 81d5373..878eb64 100644
--- a/src/frontends/qt4/GuiApplication.cpp
+++ b/src/frontends/qt4/GuiApplication.cpp
@@ -1735,12 +1735,12 @@ void GuiApplication::dispatch(FuncRequest const & cmd, 
DispatchResult & dr)
        }
 
        case LFUN_SET_COLOR: {
-               string lyx_name;
-               string const x11_name = split(to_utf8(cmd.argument()), 
lyx_name, ' ');
+               string lyx_name = cmd.getArg(0);
+               string x11_name = cmd.getArg(1);
                if (lyx_name.empty() || x11_name.empty()) {
                        if (current_view_)
                                current_view_->message(
-                                       _("Syntax: set-color <lyx_name> 
<x11_name>"));
+                                       _("Syntax: set-color \"<lyx_name>\" 
\"<x11_name>\""));
                        break;
                }
 
-- 
2.7.4

Attachment: signature.asc
Description: PGP signature

Reply via email to