]> git.lyx.org Git - features.git/commitdiff
So long, date-insert!
authorJuergen Spitzmueller <spitz@lyx.org>
Mon, 20 Aug 2018 07:25:22 +0000 (09:25 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 18 Jun 2020 12:39:47 +0000 (14:39 +0200)
This function is superseded by info-insert date, which is much mightier
and more flexible.

19 files changed:
lib/RELEASE-NOTES
lib/doc/UserGuide.lyx
lib/doc/de/UserGuide.lyx
lib/scripts/prefs2prefs_lfuns.py
lib/scripts/prefs2prefs_prefs.py
src/FuncCode.h
src/LyXAction.cpp
src/LyXRC.cpp
src/LyXRC.h
src/Text3.cpp
src/frontends/qt4/GuiPrefs.cpp
src/frontends/qt4/GuiPrefs.h
src/frontends/qt4/ui/PrefOutputUi.ui
src/support/lyxtime.cpp
src/support/lyxtime.h
src/support/os.h
src/support/os_cygwin.cpp
src/support/os_unix.cpp
src/support/os_win32.cpp

index 2a1157eea52467f34a978040802d34a1fc6e0b0c..9fa91e3c887a9569f51c857f25ac71f00d362104 100644 (file)
 * \use_qimage
   This is no longer necessary due to the rewrite of the painter.
 
+* \date_insert_format
+  The function date-insert has been removed and superseded by info-insert date.
+  The latter does not need a pref value anymore.
+
 
 !!!The following new LyX functions have been introduced in 2.4:
 
 * info-insert buffer vcs-*: renamed to info-insert vcs *
 
 
+!!!The following LyX functions have been removed in 2.4:
+
+* date-insert: obsoleted by info-insert date.
+
+
 
 !!!The following LyX documents have been moved in 2.4:
 
index 893fe1e82eb3b35fb590054ce7d1b06d0cd16230..e648bab14a859223409a0892b29211c2d779f93b 100644 (file)
@@ -8343,14 +8343,12 @@ Verbatim
 \end_layout
 
 \begin_layout Verbatim
-
 This is Verbatim.
 \end_layout
 
 \begin_layout Verbatim
 \noindent
 \align block
-
 The following 2 lines are empty:
 \end_layout
 
@@ -8363,7 +8361,6 @@ The following 2 lines are empty:
 \end_layout
 
 \begin_layout Verbatim
-
 Almost everything is allowed in Verbatim:"%&$§#~'`
 \backslash
 }][{|
@@ -8387,7 +8384,6 @@ Verbatim
 \end_layout
 
 \begin_layout Verbatim*
-
 This is Verbatim*.
 \end_layout
 
@@ -49274,6 +49270,8 @@ text
 \end_layout
 
 \begin_layout Description
+
+\change_deleted -712698321 1534601711
 Date
 \begin_inset space ~
 \end_inset
@@ -49326,6 +49324,8 @@ For example the format
 \end_inset
 
 prints the date as day/month/year.
+\change_unchanged
+
 \end_layout
 
 \begin_layout Description
index 195168776f7eabcb63006f6db3a2c94836b75e48..3677149d2b293da6e64de56f94c9c340893a7a15 100644 (file)
@@ -8601,12 +8601,10 @@ Unformatiert
 \end_layout
 
 \begin_layout Verbatim
-
 Dies ist Unformatiert.
 \end_layout
 
 \begin_layout Verbatim
-
 Die folgenden 2 Zeilen sind leer:
 \end_layout
 
@@ -8619,7 +8617,6 @@ Die folgenden 2 Zeilen sind leer:
 \end_layout
 
 \begin_layout Verbatim
-
 Fast alles ist in Unformatiert erlaubt:"%&$§#~'`
 \backslash
 }][{|
@@ -8643,7 +8640,6 @@ Unformatiert
 \end_layout
 
 \begin_layout Verbatim*
-
 Dies ist Unformatiert*.
 \end_layout
 
@@ -47023,58 +47019,6 @@ Text
  langen Zeile ausgegeben.
 \end_layout
 
-\begin_layout Description
-Datumsformat
-\begin_inset Index idx
-status collapsed
-
-\begin_layout Plain Layout
-Datumsformat
-\end_layout
-
-\end_inset
-
-
-\begin_inset Index idx
-status collapsed
-
-\begin_layout Plain Layout
-Einstellungen ! Datumsformat
-\end_layout
-
-\end_inset
-
- Das Datumsformat kann eines oder eine Mischung der hier aufgelisteten Formate
- sein:
-\begin_inset Newline newline
-\end_inset
-
-
-\begin_inset Flex URL
-status collapsed
-
-\begin_layout Plain Layout
-
-http://man7.org/linux/man-pages/man1/date.1.html
-\end_layout
-
-\end_inset
-
-
-\begin_inset Newline newline
-\end_inset
-
-Zum Beispiel gibt das Format
-\begin_inset Newline newline
-\end_inset
-
-%d/%m/%y
-\begin_inset Newline newline
-\end_inset
-
-das Datum in der Form Tag/Monat/Jahr aus.
-\end_layout
-
 \begin_layout Description
 Beim
 \begin_inset space ~
index 2ffb7f1d74ee67fdf3967cc72c8397cec99839ba..ec65f97925d8ebd69babbb45ab67a07845d47ff6 100644 (file)
@@ -217,6 +217,10 @@ def info_rename_vcstreerevision(line):
        return simple_renaming(line, "info-insert buffer vcs-tree-revision", "info-insert vcs tree-revision")
 
 
+def remove_date_insert(line):
+       return simple_remove(line, "date-insert")
+
+
 #
 ###########################################################
 
@@ -253,6 +257,7 @@ conversions = [
                info_rename_vcsdate,
                info_rename_vcstime,
                info_rename_vcsrevision,
-               info_rename_vcstreerevision
+               info_rename_vcstreerevision,
+               remove_date_insert
        ]]
 ]
index 8ea20723ab5286bf63106cc7def69d7fd0900c3b..5e7c0bf62795c1c9ebf8e1bb7799aed73776cd58 100644 (file)
 # Incremented to format 27, by spitz
 #   Add optional flavor value to needaux flag
 
+# Incremented to format 28, by spitz
+#   Remove date_insert_format
+
 # NOTE: The format should also be updated in LYXRC.cpp and
 # in configure.py.
 
@@ -405,6 +408,11 @@ def remove_font_encoding(line):
                return no_match
        return (True, "")
 
+def remove_date_insert_format(line):
+       if not line.lower().startswith("\\date_insert_format "):
+               return no_match
+       return (True, "")
+
 # End conversions for LyX 2.3 to 2.4
 ####################################
 
@@ -446,5 +454,6 @@ conversions = [
        [ 24, [rename_collapsible]],
        [ 25, [remove_use_qimage]],
        [ 26, [remove_font_encoding]],
-       [ 27, []]
+       [ 27, []],
+       [ 28, [remove_date_insert_format]]
 ]
index 7b8fedc435bb12337fc7de8bea6eda2659dda9c5..3798786018df347a3aafa5c815c64f26cf31f32e 100644 (file)
@@ -241,7 +241,7 @@ enum FuncCode
        LFUN_PREFERENCES_SAVE,
        LFUN_HELP_OPEN,                 // Jug 990627
        // 175
-       LFUN_DATE_INSERT,               // jdblair 20000131
+       LFUN_LAYOUT_TOGGLE,             // lasgouttes 20180514
        LFUN_LANGUAGE,                  // Dekel 20000203
        LFUN_ERT_INSERT,                // Jug 20000218
        LFUN_FOOTNOTE_INSERT,           // Jug 20000307
@@ -479,9 +479,8 @@ enum FuncCode
        LFUN_BUFFER_ANONYMIZE,          // sanda, 20180201
        LFUN_GRAPHICS_UNIFY,            // sanda, 20180207
        LFUN_MASTER_BUFFER_EXPORT,      // rkh, 20180417
-       LFUN_LAYOUT_TOGGLE,             // lasgouttes 20180514
-       // 375
        LFUN_INSET_END_EDIT,            // gb/rkh, 20180605
+       // 375
        LFUN_LASTACTION                 // end of the table
 };
 
index 4f424883f7a7e207932cbbe015bd0f05f842654e..43f4e80a9988d247cff2eb5e3486c34a601b1a1c 100644 (file)
@@ -1365,19 +1365,6 @@ void LyXAction::init()
  */
                { LFUN_CUT, "cut", Noop, Edit },
 
-/*!
- * \var lyx::FuncCode lyx::LFUN_DATE_INSERT
- * \li Action: Inserts the current date.
- * \li Syntax: date-insert [<ARG>]
- * \li Params: <ARG>: Format of date. The default value (%x) can be set
-                      in Preferences->Output->General->Date format. For
-                      possible formats see the manual page of the
-                      strftime function.
- * \li Origin: jdblair, 31 Jan 2000
- * \endvar
- */
-               { LFUN_DATE_INSERT, "date-insert", Noop, Edit },
-
 /*!
  * \var lyx::FuncCode lyx::LFUN_DEBUG_LEVEL_SET
  * \li Action: Set debug output level.
index 5e8d38c79893e250f4a00c3ace23409edb6d17eb..d11181fcc52c9c60f16018ce3a33673c6213e240 100644 (file)
@@ -59,7 +59,7 @@ namespace {
 
 // The format should also be updated in configure.py, and conversion code
 // should be added to prefs2prefs_prefs.py.
-static unsigned int const LYXRC_FILEFORMAT = 27; // spitz: add flavor value to needaux flag
+static unsigned int const LYXRC_FILEFORMAT = 28; // spitz: remove \\date_insert_format
 // when adding something to this array keep it sorted!
 LexerKeyword lyxrcTags[] = {
        { "\\accept_compound", LyXRC::RC_ACCEPT_COMPOUND },
@@ -92,7 +92,6 @@ LexerKeyword lyxrcTags[] = {
        { "\\copier", LyXRC::RC_COPIER },
        { "\\cursor_follows_scrollbar", LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR },
        { "\\cursor_width", LyXRC::RC_CURSOR_WIDTH },
-       { "\\date_insert_format", LyXRC::RC_DATE_INSERT_FORMAT },
        { "\\def_file", LyXRC::RC_DEFFILE },
        { "\\default_decimal_point", LyXRC::RC_DEFAULT_DECIMAL_POINT },
        { "\\default_length_unit", LyXRC::RC_DEFAULT_LENGTH_UNIT },
@@ -311,7 +310,6 @@ void LyXRC::setDefaults()
        show_banner = true;
        windows_style_tex_paths = false;
        tex_allows_spaces = false;
-       date_insert_format = "%x";
        cursor_follows_scrollbar = false;
        scroll_below_document = false;
        scroll_wheel_zoom = SCROLL_WHEEL_ZOOM_CTRL;
@@ -917,9 +915,6 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format)
                        if (lexrc.next())
                                default_length_unit = (Length::UNIT) lexrc.getInteger();
                        break;
-               case RC_DATE_INSERT_FORMAT:
-                       lexrc >> date_insert_format;
-                       break;
                case RC_LANGUAGE_CUSTOM_PACKAGE:
                        lexrc >> language_custom_package;
                        break;
@@ -1592,15 +1587,6 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
                if (tag != RC_LAST)
                        break;
                // fall through
-       case RC_DATE_INSERT_FORMAT:
-               if (ignore_system_lyxrc ||
-                   date_insert_format != system_lyxrc.date_insert_format) {
-                       os << "\\date_insert_format \"" << date_insert_format
-                          << "\"\n";
-               }
-               if (tag != RC_LAST)
-                       break;
-               // fall through
        case RC_USER_NAME:
                os << "\\user_name \"" << user_name << "\"\n";
                if (tag != RC_LAST)
@@ -2913,7 +2899,6 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
        case LyXRC::RC_COPIER:
        case LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR:
        case LyXRC::RC_SCROLL_BELOW_DOCUMENT:
-       case LyXRC::RC_DATE_INSERT_FORMAT:
        case LyXRC::RC_GUI_LANGUAGE:
        case LyXRC::RC_DEFAULT_OTF_VIEW_FORMAT:
        case LyXRC::RC_DEFAULT_PLATEX_VIEW_FORMAT:
@@ -3153,11 +3138,6 @@ string const LyXRC::getDescription(LyXRCTags tag)
                str = _("Show a small box around a Math Macro with the macro name when the cursor is inside.");
                break;
 
-       case RC_DATE_INSERT_FORMAT:
-               //xgettext:no-c-format
-               str = _("This accepts the normal strftime formats; see man strftime for full details. E.g.\"%A, %e. %B %Y\".");
-               break;
-
        case RC_DEFFILE:
                str = _("Command definition file. Can either specify an absolute path, or LyX will look in its global and local commands/ directories.");
                break;
index b499c7aebfaa5fba7ee9e77bdb3304a1c4f62cef..8a371d902c88e79d463fc5763c1795688e55c3b1 100644 (file)
@@ -66,7 +66,6 @@ public:
                RC_COPIER,
                RC_CURSOR_FOLLOWS_SCROLLBAR,
                RC_CURSOR_WIDTH,
-               RC_DATE_INSERT_FORMAT,
                RC_DEFAULT_DECIMAL_POINT,
                RC_DEFAULT_LENGTH_UNIT,
                RC_DEFAULT_OTF_VIEW_FORMAT,
@@ -357,8 +356,6 @@ public:
        ///
        std::string lyxpipes;
        ///
-       std::string date_insert_format;
-       ///
        std::string language_custom_package;
        ///
        bool language_auto_begin;
index 7d1142c13929f9f7b70f2c70183d7340decea7bb..918064c3363728a5306a07689724b399eb21fe77 100644 (file)
@@ -1750,14 +1750,6 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                break;
        }
 
-       case LFUN_DATE_INSERT: {
-               string const format = cmd.argument().empty()
-                       ? lyxrc.date_insert_format : to_utf8(cmd.argument());
-               string const time = formatted_time(current_time(), format);
-               lyx::dispatch(FuncRequest(LFUN_SELF_INSERT, time));
-               break;
-       }
-
        case LFUN_MOUSE_TRIPLE:
                if (cmd.button() == mouse_button::button1) {
                        tm->cursorHome(cur);
@@ -3271,13 +3263,6 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
                enable = !inDescriptionItem(cur);
                break;
 
-       case LFUN_DATE_INSERT: {
-               string const format = cmd.argument().empty()
-                       ? lyxrc.date_insert_format : to_utf8(cmd.argument());
-               enable = support::os::is_valid_strftime(format);
-               break;
-       }
-
        case LFUN_LANGUAGE:
                enable = !cur.paragraph().isPassThru();
                flag.setOnOff(cmd.getArg(0) == cur.real_current_font.language()->lang());
index f79d4d3f2893c76ad3e1beacc2fd2b54aadfcc03..c08245c858d9c05535c4d36acbeb119dead7a9d8 100644 (file)
@@ -349,35 +349,6 @@ static void setComboxFont(QComboBox * cb, string const & family,
 }
 
 
-/////////////////////////////////////////////////////////////////////
-//
-// StrftimeValidator
-//
-/////////////////////////////////////////////////////////////////////
-
-class StrftimeValidator : public QValidator
-{
-public:
-       StrftimeValidator(QWidget *);
-       QValidator::State validate(QString & input, int & pos) const;
-};
-
-
-StrftimeValidator::StrftimeValidator(QWidget * parent)
-       : QValidator(parent)
-{
-}
-
-
-QValidator::State StrftimeValidator::validate(QString & input, int & /*pos*/) const
-{
-       if (is_valid_strftime(fromqstr(input)))
-               return QValidator::Acceptable;
-       else
-               return QValidator::Intermediate;
-}
-
-
 /////////////////////////////////////////////////////////////////////
 //
 // PrefOutput
@@ -389,12 +360,9 @@ PrefOutput::PrefOutput(GuiPreferences * form)
 {
        setupUi(this);
 
-       DateED->setValidator(new StrftimeValidator(DateED));
        dviCB->setValidator(new NoNewLineValidator(dviCB));
        pdfCB->setValidator(new NoNewLineValidator(pdfCB));
 
-       connect(DateED, SIGNAL(textChanged(QString)),
-               this, SIGNAL(changed()));
        connect(plaintextLinelengthSB, SIGNAL(valueChanged(int)),
                this, SIGNAL(changed()));
        connect(overwriteCO, SIGNAL(activated(int)),
@@ -430,19 +398,8 @@ PrefOutput::PrefOutput(GuiPreferences * form)
 }
 
 
-void PrefOutput::on_DateED_textChanged(const QString &)
-{
-       QString t = DateED->text();
-       int p = 0;
-       bool valid = DateED->validator()->validate(t, p)
-                    == QValidator::Acceptable;
-       setValid(DateLA, valid);
-}
-
-
 void PrefOutput::applyRC(LyXRC & rc) const
 {
-       rc.date_insert_format = fromqstr(DateED->text());
        rc.plaintext_linelen = plaintextLinelengthSB->value();
        rc.forward_search_dvi = fromqstr(dviCB->currentText());
        rc.forward_search_pdf = fromqstr(pdfCB->currentText());
@@ -467,7 +424,6 @@ void PrefOutput::applyRC(LyXRC & rc) const
 
 void PrefOutput::updateRC(LyXRC const & rc)
 {
-       DateED->setText(toqstr(rc.date_insert_format));
        plaintextLinelengthSB->setValue(rc.plaintext_linelen);
        dviCB->setEditText(toqstr(rc.forward_search_dvi));
        pdfCB->setEditText(toqstr(rc.forward_search_pdf));
@@ -3440,7 +3396,6 @@ GuiPreferences::GuiPreferences(GuiView & lv)
        addModule(new PrefLanguage(this));
        addModule(new PrefSpellchecker(this));
 
-       //for strftime validator
        PrefOutput * output = new PrefOutput(this);
        addModule(output);
        addModule(new PrefLatex(this));
@@ -3464,9 +3419,6 @@ GuiPreferences::GuiPreferences(GuiView & lv)
        bc().setApply(buttonBox->button(QDialogButtonBox::Apply));
        bc().setCancel(buttonBox->button(QDialogButtonBox::Cancel));
        bc().setRestore(buttonBox->button(QDialogButtonBox::Reset));
-
-       // initialize the strftime validator
-       bc().addCheckedLineEdit(output->DateED);
 }
 
 
index 4f564992d92816e80551042d599b713e689e4f04..d6f76021138b1a66b18c76d9a9361aa98e0abbdf 100644 (file)
@@ -163,9 +163,6 @@ public:
 
        virtual void applyRC(LyXRC & rc) const;
        virtual void updateRC(LyXRC const & rc);
-
-private Q_SLOTS:
-       void on_DateED_textChanged(const QString &);
 };
 
 
index 0c24c05fbe041d9a4f9a404696ac2afae8202b5c..f8c8a8270cc72664f7adfd7914389a03d0a788fa 100644 (file)
@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>356</width>
-    <height>393</height>
+    <height>442</height>
    </rect>
   </property>
   <property name="windowTitle">
         </item>
        </layout>
       </item>
-      <item>
-       <layout class="QHBoxLayout" name="horizontalLayout_7">
-        <item>
-         <widget class="QLabel" name="DateLA">
-          <property name="text">
-           <string>&amp;Date format:</string>
-          </property>
-          <property name="buddy">
-           <cstring>DateED</cstring>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <widget class="QLineEdit" name="DateED">
-          <property name="sizePolicy">
-           <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
-            <horstretch>0</horstretch>
-            <verstretch>0</verstretch>
-           </sizepolicy>
-          </property>
-          <property name="toolTip">
-           <string>Date format for strftime output</string>
-          </property>
-         </widget>
-        </item>
-       </layout>
-      </item>
       <item>
        <layout class="QHBoxLayout" name="horizontalLayout_8">
         <item>
index 5415ac4eeb034057234b363d3931d7d004ca40ba..f3318eb3f0e35aeea8bf98021c1fb84a1061c11e 100644 (file)
@@ -31,15 +31,6 @@ time_t current_time()
 }
 
 
-string const formatted_time(time_t t, string const & fmt)
-{
-       struct tm * loc_tm = localtime(&t);
-       char date[50];
-       strftime(date, sizeof(date), fmt.c_str(), loc_tm);
-       return string(date);
-}
-
-
 docstring formatted_datetime(time_t t, string const & fmt)
 {
        QString qres;
index bc545b8c5de643a21f888ef6eb49d9196c3e93ed..05cbc508411be0e8cec72cf05ff75b29bb874c78 100644 (file)
@@ -24,13 +24,6 @@ namespace support {
 
 time_t current_time();
 
-/** Returns a locale-dependent formatting of the date
- *  and time encoded in \c time. The \p fmt string
- *  holds the formatting arguments of \c strftime.
- *  Prefer the function formatted_datetime below.
- */
-std::string const formatted_time(time_t t, std::string const & fmt);
-
 /** Returns a locale-dependent formatting of the date and time encoded in \c t
  *  The \p fmt string holds the formatting arguments of QDateTime::toString().
  *  If fmt is empty then the formatting of the date and time is itself according
index 9b38e4e44ee0272de8b5caf9be74e195ccc6ec5a..07d6d7ba76cf5398e449ed676835637cb9c22acb 100644 (file)
@@ -111,9 +111,6 @@ std::string latex_path(std::string const & p);
  */
 std::string latex_path_list(std::string const & p);
 
-/// Checks if the format string is suitable on the OS
-bool is_valid_strftime(std::string const & p);
-
 /** Returns a string suitable to be passed to popen when
  *  reading a file.
  */
index 64436f115aff943bf1a90eb0172c876c532b277e..5d4373780730522867642f90565d1437e313c52d 100644 (file)
@@ -364,23 +364,6 @@ string latex_path_list(string const & p)
 }
 
 
-bool is_valid_strftime(string const & p)
-{
-       string::size_type pos = p.find_first_of('%');
-       while (pos != string::npos) {
-               if (pos + 1 == string::npos)
-                       break;
-               if (!containsOnly(p.substr(pos + 1, 1),
-                       "aAbBcCdDeEFgGhHIjklmMnOpPrRsStTuUVwWxXyYzZ%+"))
-                       return false;
-               if (pos + 2 == string::npos)
-                     break;
-               pos = p.find_first_of('%', pos + 2);
-       }
-       return true;
-}
-
-
 // returns a string suitable to be passed to popen when
 // reading a pipe
 char const * popen_read_mode()
index 5a6c21fe63e72e98ca31e278e1c56ab3b8ba5d5f..34cfd478a61650ce9bcb0beec5a204886bd34dee 100644 (file)
@@ -193,23 +193,6 @@ string latex_path_list(string const & p)
 }
 
 
-bool is_valid_strftime(string const & p)
-{
-       string::size_type pos = p.find_first_of('%');
-       while (pos != string::npos) {
-               if (pos + 1 == string::npos)
-                       break;
-               if (!containsOnly(p.substr(pos + 1, 1),
-                       "aAbBcCdDeEFgGhHIjklmMnOpPrRsStTuUVwWxXyYzZ%+"))
-                       return false;
-               if (pos + 2 == string::npos)
-                     break;
-               pos = p.find_first_of('%', pos + 2);
-       }
-       return true;
-}
-
-
 char const * popen_read_mode()
 {
        return "r";
index 8d521383f205e3dec828f379a5c1cb40bce0a68f..145d5065923c7ce80deac55f66a82cf03d539775 100644 (file)
@@ -442,23 +442,6 @@ string latex_path_list(string const & p)
 }
 
 
-bool is_valid_strftime(string const & p)
-{
-       string::size_type pos = p.find_first_of('%');
-       while (pos != string::npos) {
-               if (pos + 1 == string::npos)
-                       break;
-               if (!containsOnly(p.substr(pos + 1, 1),
-                       "aAbBcdfHIjmMpSUwWxXyYzZ%"))
-                       return false;
-               if (pos + 2 == string::npos)
-                     break;
-               pos = p.find_first_of('%', pos + 2);
-       }
-       return true;
-}
-
-
 // returns a string suitable to be passed to popen when
 // reading a pipe
 char const * popen_read_mode()