Op 29-4-2012 11:29, Stephan Witt schreef:
This patch restores the font toggle feature if there is no selection.
I looked into this and it is that way:

Given one invokes the LFUN_LANGUAGE with a value different from current one at 
current position.
Then the language is changed to the new value. If one passes the current one 
the language it is
set (back) to the document or default language.

E. g. one has document language english. The first call of "language hebrew" 
switches to hebrew.
The next call of "language hebrew" switches back to english.

Now I want to ask: is this a bug or a feature? The patch I've posted restores 
the old behavior.
So it is not bad. But is it good? If nobody objects I'd like to commit that 
thing.

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.

See the attached.

Vincent
>From 0cb9d96ec07bc1078d0e100eea17caff326e4fcd Mon Sep 17 00:00:00 2001
From: Vincent van Ravesteijn <v...@lyx.org>
Date: Sun, 29 Apr 2012 14:06:21 +0200
Subject: [PATCH] Fix toggling of languages

As LFUN_LANGAUGE does no longer toggles the language, we need to disable
the current language to make a command-alternatives command work.

Example of an LFUN to toggle between hebrew and english:
  command-alternatives language hebrew; language english
---
 src/Text3.cpp |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/Text3.cpp b/src/Text3.cpp
index 9bb3f25..8394973 100644
--- a/src/Text3.cpp
+++ b/src/Text3.cpp
@@ -2690,10 +2690,14 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & 
cmd,
                break;
        }
 
-       case LFUN_LANGUAGE:
+       case LFUN_LANGUAGE: {
                enable = !cur.paragraph().isPassThru();
-               flag.setOnOff(to_utf8(cmd.argument()) == 
cur.real_current_font.language()->lang());
+               bool const same_lang = ascii_lowercase(to_utf8(cmd.argument())) 
+                       == 
ascii_lowercase(cur.real_current_font.language()->lang());
+               enable &= !same_lang;
+               flag.setOnOff(same_lang);
                break;
+       }
 
        case LFUN_BREAK_PARAGRAPH:
                enable = cur.inset().getLayout().isMultiPar();
-- 
1.7.9.msysgit.0

Reply via email to