[prev in list] [next in list] [prev in thread] [next in thread]
List: lyx-devel
Subject: Re: annoying behavior of Lyx 2.02+ -- Language toggle
From: Ronen Abravanel <ronena () gmail ! com>
Date: 2012-05-25 11:21:23
Message-ID: CACTp8RhL+wVg_SdRzi8u8f+eqLK0XX3i0_AMK3as6wfZQxeq8w () mail ! gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
I added an optional "set" argument to LFUN_LANGUAGE and fixed the menu
entery.
Anythhing else? Should I fix the LFUN documentation?
On Wed, May 23, 2012 at 11:37 PM, Stephan Witt <st.witt@gmx.net> wrote:
> Currently I'm really short on time.
>
> I'd vote for keeping the "traditional" behavior and add the optional
> argument "set" for internal API use.
> This has to be used by the context menu code.
>
> Stephan
>
> Am 23.05.2012 um 20:59 schrieb Ronen Abravanel:
>
> > So, which one of the suggestions should I implement?
> >
> > On Mon, May 7, 2012 at 1:39 PM, Ronen Abravanel <ronena@gmail.com>
> wrote:
> > If there are only few such commands, the 1st options seems best.
> > If there are many, the last..
> >
> > Ronen
> >
> >
> > On Wed, May 2, 2012 at 11:58 AM, Jean-Marc Lasgouttes <
> lasgouttes@lyx.org> wrote:
> > Le 29/04/2012 14:13, Vincent van Ravesteijn a =C3=A9crit :
> >
> > I think it is a bug. I would vote for disabling the LFUN when the
> > languages are the same. This will make it possible for the reporter to
> > define: "command-alternatives language hebrew; language english" to
> toggle.
> >
> > I especially object to introduce a difference in behaviour based on the
> > fact whether there is a selection or not. I would not expect something
> > different to happen.
> >
> > I think these lfuns have two faces: interactive and API.
> > * as an API, I would expect to be able to set language to "french" and
> not care about what the language was before that
> > * as an interactive function, toggling between the given value and the
> default is very desirable and fits what is done by other font-changing
> functions.
> >
> > We probably need to offer the two possibilities, either by
> > * two sets of lfuns language/language-set, font-emph/font-emph-set
> > * an optional argument "set"
> > * a prefix command "notoggle" ("notoggle language french")
> >
> > Of course, a way that preserves the preexisting semantics of lfuns woul=
d
> be best.
> >
> > Similarly, having the possibility to have "layout" toggle between the
> given layout and standard layout could be useful for toolbars.
> >
> > JMarc
> >
> >
>
>
[Attachment #5 (text/html)]
<div dir="ltr">I added an optional "set" argument to LFUN_LANGUAGE and \
fixed the menu entery.<br><br>Anythhing else? Should I fix the LFUN \
documentation?<br><br><div class="gmail_quote">On Wed, May 23, 2012 at 11:37 PM, \
Stephan Witt <span dir="ltr"><<a href="mailto:st.witt@gmx.net" \
target="_blank">st.witt@gmx.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex">Currently I'm really short on time.<br> <br>
I'd vote for keeping the "traditional" behavior and add the optional \
argument "set" for internal API use.<br> This has to be used by the context \
menu code.<br> <br>
Stephan<br>
<br>
Am 23.05.2012 um 20:59 schrieb Ronen Abravanel:<br>
<div class="HOEnZb"><div class="h5"><br>
> So, which one of the suggestions should I implement?<br>
><br>
> On Mon, May 7, 2012 at 1:39 PM, Ronen Abravanel <<a \
href="mailto:ronena@gmail.com">ronena@gmail.com</a>> wrote:<br> > If there are \
only few such commands, the 1st options seems best.<br> > If there are many, the \
last..<br> ><br>
> Ronen<br>
><br>
><br>
> On Wed, May 2, 2012 at 11:58 AM, Jean-Marc Lasgouttes <<a \
href="mailto:lasgouttes@lyx.org">lasgouttes@lyx.org</a>> wrote:<br> > Le \
29/04/2012 14:13, Vincent van Ravesteijn a écrit :<br> ><br>
> I think it is a bug. I would vote for disabling the LFUN when the<br>
> languages are the same. This will make it possible for the reporter to<br>
> define: "command-alternatives language hebrew; language english" to \
toggle.<br> ><br>
> I especially object to introduce a difference in behaviour based on the<br>
> fact whether there is a selection or not. I would not expect something<br>
> different to happen.<br>
><br>
> I think these lfuns have two faces: interactive and API.<br>
> * as an API, I would expect to be able to set language to "french" and \
not care about what the language was before that<br> > * as an interactive \
function, toggling between the given value and the default is very desirable and fits \
what is done by other font-changing functions.<br> ><br>
> We probably need to offer the two possibilities, either by<br>
> * two sets of lfuns language/language-set, font-emph/font-emph-set<br>
> * an optional argument "set"<br>
> * a prefix command "notoggle" ("notoggle language \
french")<br> ><br>
> Of course, a way that preserves the preexisting semantics of lfuns would be \
best.<br> ><br>
> Similarly, having the possibility to have "layout" toggle between the \
given layout and standard layout could be useful for toolbars.<br> ><br>
> JMarc<br>
><br>
><br>
<br>
</div></div></blockquote></div><br></div>
--e89a8ff1c5c6c596eb04c0da92d7--
["language_toggle_set.patch" (application/octet-stream)]
diff --git a/src/Text3.cpp b/src/Text3.cpp
index 9bb3f25..b701251 100644
--- a/src/Text3.cpp
+++ b/src/Text3.cpp
@@ -1916,12 +1916,20 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
}
case LFUN_LANGUAGE: {
- Language const * lang = languages.getLanguage(to_utf8(cmd.argument()));
+
+ Language const * lang = languages.getLanguage(cmd.getArg(0));
if (!lang)
break;
+
+ bool toggleLanguage = true;
+ if (cmd.getArg(1) == "set")
+ {
+ toggleLanguage = false;
+ }
+
selectWordWhenUnderCursor(cur, WHOLE_WORD_STRICT);
Font font(ignore_font, lang);
- toggleAndShow(cur, this, font, false);
+ toggleAndShow(cur, this, font, toggleLanguage);
break;
}
diff --git a/src/frontends/qt4/Menus.cpp b/src/frontends/qt4/Menus.cpp
index 9e81527..fe8ae01 100644
--- a/src/frontends/qt4/Menus.cpp
+++ b/src/frontends/qt4/Menus.cpp
@@ -883,7 +883,7 @@ void MenuDefinition::expandLanguageSelector(Buffer const * buf)
}
}
MenuItem w(MenuItem::Command, label,
- FuncRequest(LFUN_LANGUAGE, (*cit)->lang()));
+ FuncRequest(LFUN_LANGUAGE, (*cit)->lang() + " set"));
item.submenu().addWithStatusCheck(w);
}
item.submenu().add(MenuItem(MenuItem::Separator));
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic