Le 13/11/2015 14:15, Jean-Marc Lasgouttes a écrit :
Le 13/11/2015 00:36, Uwe Stöhr a écrit :
I noticed that we don't have an LFUN to toggle the longtable and the
booktabs. I therefore added now 2 entries to return to the default
settings, despite I would like to have only 2 entries that toggle the
feature.

Like the patch below? Note that I renamed Dialog Settings to Settings...
like everywhere else.

Oops.

JMarc

>From 26a43238014b738f9b4ca7c5df149a8654a7b8b8 Mon Sep 17 00:00:00 2001
From: Jean-Marc Lasgouttes <lasgout...@lyx.org>
Date: Fri, 13 Nov 2015 14:09:04 +0100
Subject: [PATCH] Implement toggling for longtabular and booktabs tabular
 features

This is needed for the tabular context menu. This menu is updated accordingly.
---
 lib/ui/stdcontext.inc       |   15 ++++++---------
 src/insets/InsetTabular.cpp |   15 +++++++++++++++
 src/insets/InsetTabular.h   |    4 ++++
 3 files changed, 25 insertions(+), 9 deletions(-)

diff --git a/lib/ui/stdcontext.inc b/lib/ui/stdcontext.inc
index 1b3b618..b5b1673 100644
--- a/lib/ui/stdcontext.inc
+++ b/lib/ui/stdcontext.inc
@@ -411,7 +411,7 @@ Menuset
 		Item "Left|L" "inset-modify tabular toggle-line-left"
 		Item "Right|R" "inset-modify tabular toggle-line-right"
 	End
-	
+
 	Menu "table-alignment"
 		Item "Left|f" "command-alternatives inset-modify tabular m-align-left;inset-modify tabular align-left"
 		Item "Center|C" "command-alternatives inset-modify tabular m-align-center;inset-modify tabular align-center"
@@ -422,7 +422,7 @@ Menuset
 		Item "Middle" "inset-modify tabular valign-middle"
 		Item "Bottom" "inset-modify tabular valign-bottom"
 	End
-	
+
 	Menu "table-cols-rows"
 		Item "Multicolumn|u" "inset-modify tabular multicolumn"
 		Item "Multirow|w" "inset-modify tabular multirow"
@@ -439,19 +439,16 @@ Menuset
 		Item "Move Column Right|v" "inset-modify tabular move-column-right"
 		Item "Move Column Left" "inset-modify tabular move-column-left"
 	End
-	
+
 	Menu "context-tabular"
-		Item "Normal Table|g" "inset-modify tabular unset-longtabular"		
-		Item "Breakable Table|g" "inset-modify tabular set-longtabular"
-		Separator
-		Item "Default Style|m" "inset-modify tabular unset-booktabs"
-		Item "Formal Style|m" "inset-modify tabular set-booktabs"
+		Item "Breakable Table|g" "inset-modify tabular toggle-longtabular"
+		Item "Formal Style|m" "inset-modify tabular toggle-booktabs"
 		Separator
 		Submenu "Borders|d" "table-borders"
 		Submenu "Alignment|i" "table-alignment"
 		Submenu "Columns/Rows|C" "table-cols-rows"
 		Separator
-		Item "Settings Dialog...|S" "inset-settings tabular"
+		Item "Settings...|S" "inset-settings tabular"
 	End
 
 #
diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp
index b8b47f7..437ac7e 100644
--- a/src/insets/InsetTabular.cpp
+++ b/src/insets/InsetTabular.cpp
@@ -151,6 +151,7 @@ TabularFeature tabularFeature[] =
 	{ Tabular::SET_MROFFSET, "set-mroffset", true },
 	{ Tabular::SET_ALL_LINES, "set-all-lines", false },
 	{ Tabular::UNSET_ALL_LINES, "unset-all-lines", false },
+	{ Tabular::TOGGLE_LONGTABULAR, "toggle-longtabular", false },
 	{ Tabular::SET_LONGTABULAR, "set-longtabular", false },
 	{ Tabular::UNSET_LONGTABULAR, "unset-longtabular", false },
 	{ Tabular::SET_PWIDTH, "set-pwidth", true },
@@ -177,6 +178,7 @@ TabularFeature tabularFeature[] =
 	{ Tabular::UNSET_LTCAPTION, "unset-ltcaption", false },
 	{ Tabular::SET_SPECIAL_COLUMN, "set-special-column", true },
 	{ Tabular::SET_SPECIAL_MULTICOLUMN, "set-special-multicolumn", true },
+	{ Tabular::TOGGLE_BOOKTABS, "toggle-booktabs", false },
 	{ Tabular::SET_BOOKTABS, "set-booktabs", false },
 	{ Tabular::UNSET_BOOKTABS, "unset-booktabs", false },
 	{ Tabular::SET_TOP_SPACE, "set-top-space", true },
@@ -4718,6 +4720,7 @@ bool InsetTabular::getStatus(Cursor & cur, FuncRequest const & cmd,
 			break;
 
 		case Tabular::SET_LONGTABULAR:
+		case Tabular::TOGGLE_LONGTABULAR:
 			// setting as longtable is not allowed when table is inside a float
 			if (cur.innerInsetOfType(FLOAT_CODE) != 0
 				|| cur.innerInsetOfType(WRAP_CODE) != 0)
@@ -4866,6 +4869,7 @@ bool InsetTabular::getStatus(Cursor & cur, FuncRequest const & cmd,
 			status.setOnOff(tabular.ltCaption(sel_row_start));
 			break;
 
+		case Tabular::TOGGLE_BOOKTABS:
 		case Tabular::SET_BOOKTABS:
 			status.setOnOff(tabular.use_booktabs);
 			break;
@@ -5761,6 +5765,13 @@ void InsetTabular::tabularFeatures(Cursor & cur,
 		}
 		break;
 
+	case Tabular::TOGGLE_LONGTABULAR:
+		if (tabular.is_long_tabular)
+			tabularFeatures(cur, Tabular::UNSET_LONGTABULAR);
+		else
+			tabular.is_long_tabular = true;
+		break;
+
 	case Tabular::SET_LONGTABULAR:
 		tabular.is_long_tabular = true;
 		break;
@@ -5929,6 +5940,10 @@ void InsetTabular::tabularFeatures(Cursor & cur,
 		break;
 	}
 
+	case Tabular::TOGGLE_BOOKTABS:
+		tabular.use_booktabs = !tabular.use_booktabs;
+		break;
+
 	case Tabular::SET_BOOKTABS:
 		tabular.use_booktabs = true;
 		break;
diff --git a/src/insets/InsetTabular.h b/src/insets/InsetTabular.h
index a3c2b86..d9b7fa4 100644
--- a/src/insets/InsetTabular.h
+++ b/src/insets/InsetTabular.h
@@ -219,6 +219,8 @@ public:
 		///
 		UNSET_ALL_LINES,
 		///
+		TOGGLE_LONGTABULAR,
+		///
 		SET_LONGTABULAR,
 		///
 		UNSET_LONGTABULAR,
@@ -266,6 +268,8 @@ public:
 		///
 		SET_SPECIAL_MULTICOLUMN,
 		///
+		TOGGLE_BOOKTABS,
+		///
 		SET_BOOKTABS,
 		///
 		UNSET_BOOKTABS,
-- 
1.7.9.5

Reply via email to