mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
make branch-add-insert aware of the separator ("|") [bug #6621]
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34653 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
47aeddab07
commit
c8faa01f4f
@ -93,6 +93,9 @@ public:
|
||||
///
|
||||
BranchList() : separator_(from_ascii("|")) {}
|
||||
|
||||
///
|
||||
docstring separator() const { return separator_; }
|
||||
|
||||
///
|
||||
bool empty() const { return list.empty(); }
|
||||
///
|
||||
|
@ -1983,28 +1983,37 @@ void Buffer::dispatch(FuncRequest const & func, DispatchResult & dr)
|
||||
break;
|
||||
|
||||
case LFUN_BRANCH_ADD: {
|
||||
docstring const branch_name = func.argument();
|
||||
docstring branch_name = func.argument();
|
||||
if (branch_name.empty()) {
|
||||
dispatched = false;
|
||||
break;
|
||||
}
|
||||
BranchList & branch_list = params().branchlist();
|
||||
Branch * branch = branch_list.find(branch_name);
|
||||
if (branch) {
|
||||
LYXERR0("Branch " << branch_name << " already exists.");
|
||||
dr.setError(true);
|
||||
docstring const msg =
|
||||
bformat(_("Branch \"%1$s\" already exists."), branch_name);
|
||||
dr.setMessage(msg);
|
||||
} else {
|
||||
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);
|
||||
lyx::dispatch(FuncRequest(LFUN_SET_COLOR, str));
|
||||
dr.setError(false);
|
||||
dr.update(Update::Force);
|
||||
vector<docstring> const branches =
|
||||
getVectorFromString(branch_name, branch_list.separator());
|
||||
docstring msg;
|
||||
for (vector<docstring>::const_iterator it = branches.begin();
|
||||
it != branches.end(); ++it) {
|
||||
branch_name = *it;
|
||||
Branch * branch = branch_list.find(branch_name);
|
||||
if (branch) {
|
||||
LYXERR0("Branch " << branch_name << " already exists.");
|
||||
dr.setError(true);
|
||||
if (!msg.empty())
|
||||
msg += ("\n");
|
||||
msg += bformat(_("Branch \"%1$s\" already exists."), branch_name);
|
||||
} else {
|
||||
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);
|
||||
lyx::dispatch(FuncRequest(LFUN_SET_COLOR, str));
|
||||
dr.setError(false);
|
||||
dr.update(Update::Force);
|
||||
}
|
||||
}
|
||||
if (!msg.empty())
|
||||
dr.setMessage(msg);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1730,7 +1730,14 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
|
||||
Alert::warning(_("Branch already exists"), drtmp.message());
|
||||
break;
|
||||
}
|
||||
lyx::dispatch(FuncRequest(LFUN_BRANCH_INSERT, branch_name));
|
||||
BranchList & branch_list = buffer_.params().branchlist();
|
||||
vector<docstring> const branches =
|
||||
getVectorFromString(branch_name, branch_list.separator());
|
||||
for (vector<docstring>::const_iterator it = branches.begin();
|
||||
it != branches.end(); ++it) {
|
||||
branch_name = *it;
|
||||
lyx::dispatch(FuncRequest(LFUN_BRANCH_INSERT, branch_name));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user