Index: abiword-src/src/text/fmt/xp/fl_DocLayout.h =================================================================== --- abiword-src/src/text/fmt/xp/fl_DocLayout.h (.../http://svn.abisource.com/abiword/trunk) (revision 22791) +++ abiword-src/src/text/fmt/xp/fl_DocLayout.h (.../abiword-src) (working copy) @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA * 02111-1307, USA. */ - + #ifndef DOCLAYOUT_H #define DOCLAYOUT_H @@ -291,6 +291,9 @@ bool getSpellCheckInternet(void) const { return m_bSpellCheckInternet; } void recheckIgnoredWords(); #endif +// -------------------------------------------------------------------- + bool getSmartQuotes(void) const { return (hasBackgroundCheckReason(bgcrSmartQuotes)); } +// -------------------------------------------------------------------- inline void addBackgroundCheckReason(UT_uint32 reason) {m_uDocBackgroundCheckReasons |= reason;} inline void removeBackgroundCheckReason(UT_uint32 reason) {m_uDocBackgroundCheckReasons &= ~reason;} Index: abiword-src/src/text/fmt/xp/fl_DocLayout.cpp =================================================================== --- abiword-src/src/text/fmt/xp/fl_DocLayout.cpp (.../http://svn.abisource.com/abiword/trunk) (revision 22791) +++ abiword-src/src/text/fmt/xp/fl_DocLayout.cpp (.../abiword-src) (working copy) @@ -3468,8 +3468,10 @@ } pPrefs->getPrefsValueBool( static_cast(XAP_PREF_KEY_SmartQuotesEnable), &b ); + + pDocLayout->_toggleAutoSmartQuotes( b ); - + const gchar * pszTransparentColor = NULL; pPrefs->getPrefsValue(static_cast(XAP_PREF_KEY_ColorForTransparent),&pszTransparentColor); if(strcmp(pszTransparentColor,pDocLayout->m_szCurrentTransparentColor) != 0) @@ -3739,11 +3741,16 @@ 6. If a QUOTE is immediately followed by a sqCLOSEPUNCT, it is converted to a curly quote in the close direction. -7. If a QUOTE is in isolation, it is not converted. It is in -isolation if it is immediately preceded and followed by either a sqBREAK -or sqWHITE. The things before and after it don't have to be of -the same type. +7. If a QUOTE is in isolation, it is converted to a curly quote +in the open direction. It is in isolation if it is immediately +preceded and followed by either a sqBREAK or sqWHITE. The things +before and after it don't have to be of the same type. +Rule 7 was originally that it didin't convert. This does not make +sense because the most common use of smart quotes is as you're typing +where there is often a space before and nothing after (since it hasn't +been written yet!) -- Bobby Weinmann Feb 4, 2008 + 8. If a QUOTE is immediately preceded by a sqBREAK or sqWHITE and is immediately followed by anything other than a sqBREAK or sqWHITE, it is converted to the opening form of curly quote. @@ -3783,7 +3790,7 @@ want to save proposals for that to be separate from the basic algorithm. */ -#if 0 + // The following are descriptions of the thing before or after a // character being considered for smart quote promotion. The thing // is either a structural break in a document, or it is a literal @@ -3906,20 +3913,20 @@ {sqDONTCARE, '`', sqCLOSEPUNCT, UCS_RQUOTE}, // rule 6 {sqDONTCARE, '"', sqCLOSEPUNCT, UCS_RDBLQUOTE}, // rule 6 - {sqBREAK, '\'', sqBREAK, UCS_UNKPUNK}, // rule 7 - {sqWHITE, '\'', sqBREAK, UCS_UNKPUNK}, // rule 7 + {sqBREAK, '\'', sqBREAK, UCS_LQUOTE}, // rule 7 + {sqWHITE, '\'', sqBREAK, UCS_LQUOTE}, // rule 7 {sqBREAK, '\'', sqWHITE, UCS_UNKPUNK}, // rule 7 {sqWHITE, '\'', sqWHITE, UCS_UNKPUNK}, // rule 7 - {sqBREAK, '`', sqBREAK, UCS_UNKPUNK}, // rule 7 - {sqWHITE, '`', sqBREAK, UCS_UNKPUNK}, // rule 7 + {sqBREAK, '`', sqBREAK, UCS_LQUOTE}, // rule 7 + {sqWHITE, '`', sqBREAK, UCS_LQUOTE}, // rule 7 {sqBREAK, '`', sqWHITE, UCS_UNKPUNK}, // rule 7 {sqWHITE, '`', sqWHITE, UCS_UNKPUNK}, // rule 7 - {sqBREAK, '"', sqBREAK, UCS_UNKPUNK}, // rule 7 - {sqWHITE, '"', sqBREAK, UCS_UNKPUNK}, // rule 7 - {sqBREAK, '"', sqWHITE, UCS_UNKPUNK}, // rule 7 - {sqWHITE, '"', sqWHITE, UCS_UNKPUNK}, // rule 7 + {sqBREAK, '"', sqBREAK, UCS_LDBLQUOTE}, // rule 7 + {sqWHITE, '"', sqBREAK, UCS_LDBLQUOTE}, // rule 7 + {sqBREAK, '"', sqWHITE, UCS_LDBLQUOTE}, // rule 7 + {sqWHITE, '"', sqWHITE, UCS_LDBLQUOTE}, // rule 7 {sqBREAK, '\'', sqDONTCARE, UCS_LQUOTE}, // rule 8 {sqWHITE, '\'', sqDONTCARE, UCS_LQUOTE}, // rule 8 @@ -3962,14 +3969,15 @@ else if(c == UCS_RDBLQUOTE) c = UCS_LDBLQUOTE; } -#endif + void FL_DocLayout::considerSmartQuoteCandidateAt(fl_BlockLayout *block, UT_uint32 offset) { -#if 0 if (!block) return; if (m_pView->isHdrFtrEdit()) return; + if (!getSmartQuotes()) + return; setPendingSmartQuote(NULL, 0); // avoid recursion UT_GrowBuf pgb(1024); @@ -4035,7 +4043,7 @@ { // candidate was the last character in a block, so see // what's at the beginning of the next block, if any - fl_BlockLayout *ob = static_cast(block->getNextInDocument()); + fl_BlockLayout *ob = static_cast(block->getNext()); if (ob) { fp_Run *r = ob->getFirstRun(); @@ -4104,9 +4112,6 @@ // for similar reasons. } } -#else - return; -#endif } void FL_DocLayout::notifyBlockIsBeingDeleted(fl_BlockLayout *pBlock) Index: abiword-src/src/af/xap/xp/xap_Prefs_SchemeIds.h =================================================================== --- abiword-src/src/af/xap/xp/xap_Prefs_SchemeIds.h (.../http://svn.abisource.com/abiword/trunk) (revision 22791) +++ abiword-src/src/af/xap/xp/xap_Prefs_SchemeIds.h (.../abiword-src) (working copy) @@ -53,7 +53,7 @@ /* smart quotes */ #define XAP_PREF_KEY_SmartQuotesEnable "SmartQuotesEnable" /* substitute curly smart quotes on the fly */ -#define XAP_PREF_DEFAULT_SmartQuotesEnable "0" +#define XAP_PREF_DEFAULT_SmartQuotesEnable "1" #define XAP_PREF_KEY_UseSuffix "UseSuffix" /* append suffixes to saved files */ Index: abiword-src/src/wp/ap/gtk/ap_UnixDialog_Options.glade =================================================================== --- abiword-src/src/wp/ap/gtk/ap_UnixDialog_Options.glade (.../http://svn.abisource.com/abiword/trunk) (revision 22791) +++ abiword-src/src/wp/ap/gtk/ap_UnixDialog_Options.glade (.../abiword-src) (working copy) @@ -2,7 +2,6 @@ - 5 @@ -1300,6 +1299,65 @@ tab + + + + 12 + True + False + 18 + + + + True + True + Enable smart quotes + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + + + + + False + True + + + + + + True + Smart Quotes + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + tab + + 0 Index: abiword-src/src/wp/ap/gtk/ap_UnixDialog_Options.cpp =================================================================== --- abiword-src/src/wp/ap/gtk/ap_UnixDialog_Options.cpp (.../http://svn.abisource.com/abiword/trunk) (revision 22791) +++ abiword-src/src/wp/ap/gtk/ap_UnixDialog_Options.cpp (.../abiword-src) (working copy) @@ -430,6 +430,10 @@ localizeButtonUnderline (m_checkbuttonGrammarCheck, pSS, AP_STRING_ID_DLG_Options_Label_GrammarCheck); + m_checkbuttonSmartQuotes = WID ("chkSmartQuotes"); + localizeButtonUnderline (m_checkbuttonSmartQuotes, pSS, + AP_STRING_ID_DLG_Options_Label_SmartQuotes); + ////////////////////////////////////////////////////////////////// // @@ -565,6 +569,9 @@ case id_CHECK_GRAMMAR_CHECK: return m_checkbuttonGrammarCheck; + case id_CHECK_SMART_QUOTES_ENABLE: + return m_checkbuttonSmartQuotes; + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // other case id_CHECK_OTHER_DEFAULT_DIRECTION_RTL: @@ -665,6 +672,7 @@ DEFINE_GET_SET_BOOL(SpellUppercase) DEFINE_GET_SET_BOOL(SpellNumbers) DEFINE_GET_SET_BOOL(GrammarCheck) +DEFINE_GET_SET_BOOL(SmartQuotes) DEFINE_GET_SET_BOOL(OtherDirectionRtl) Index: abiword-src/src/wp/ap/gtk/ap_UnixDialog_Options.h =================================================================== --- abiword-src/src/wp/ap/gtk/ap_UnixDialog_Options.h (.../http://svn.abisource.com/abiword/trunk) (revision 22791) +++ abiword-src/src/wp/ap/gtk/ap_UnixDialog_Options.h (.../abiword-src) (working copy) @@ -108,6 +108,10 @@ SET_GATHER (GrammarCheck, bool); + // Smart Quotes + + SET_GATHER (SmartQuotes, bool); + // unimplemented UI-wise. We need dummy implementations to satisfy the XP framework, though SET_GATHER (PrefsAutoSave, bool); @@ -190,6 +194,10 @@ GtkWidget *m_checkbuttonGrammarCheck; + // Smart Quotes + + GtkWidget *m_checkbuttonSmartQuotes; + // Dummy bool m_boolEnableSmoothScrolling; bool m_boolPrefsAutoSave; Index: abiword-src/src/wp/ap/xp/ap_String_Id.h =================================================================== --- abiword-src/src/wp/ap/xp/ap_String_Id.h (.../http://svn.abisource.com/abiword/trunk) (revision 22791) +++ abiword-src/src/wp/ap/xp/ap_String_Id.h (.../abiword-src) (working copy) @@ -371,6 +371,8 @@ // Grammar Check dcl(DLG_Options_Label_Grammar, "Automatic Grammar Checking") dcl(DLG_Options_Label_GrammarCheck, "Check &grammar as you type") + +dcl(DLG_Options_Label_SmartQuotes, "Enable smart (curly) quotes") // should be merged one day dcl(DLG_Options_Label_SpellSuggest, "A&lways suggest corrections") dcl(DLG_Options_Label_SpellMainOnly, "Suggest from &main dictionary only") Index: abiword-src/src/wp/ap/xp/ap_Dialog_Options.cpp =================================================================== --- abiword-src/src/wp/ap/xp/ap_Dialog_Options.cpp (.../http://svn.abisource.com/abiword/trunk) (revision 22791) +++ abiword-src/src/wp/ap/xp/ap_Dialog_Options.cpp (.../abiword-src) (working copy) @@ -116,6 +116,7 @@ // save the values to the Prefs classes Save_Pref_Bool( pPrefsScheme, AP_PREF_KEY_AutoSpellCheck, _gatherSpellCheckAsType() ); Save_Pref_Bool( pPrefsScheme, AP_PREF_KEY_AutoGrammarCheck, _gatherGrammarCheck() ); + Save_Pref_Bool( pPrefsScheme, XAP_PREF_KEY_SmartQuotesEnable, _gatherSmartQuotes() ); Save_Pref_Bool( pPrefsScheme, AP_PREF_KEY_SpellCheckCaps, _gatherSpellUppercase() ); Save_Pref_Bool( pPrefsScheme, AP_PREF_KEY_SpellCheckNumbers, _gatherSpellNumbers() ); Save_Pref_Bool( pPrefsScheme, AP_PREF_KEY_CursorBlink, _gatherViewCursorBlink() ); @@ -284,6 +285,11 @@ _gatherGrammarCheck()); break; + case id_CHECK_SMART_QUOTES_ENABLE: + Save_Pref_Bool (pPrefsScheme, XAP_PREF_KEY_SmartQuotesEnable, + _gatherSmartQuotes()); + break; + case id_CHECK_SPELL_UPPERCASE: Save_Pref_Bool (pPrefsScheme, AP_PREF_KEY_SpellCheckCaps, _gatherSpellUppercase()); @@ -476,6 +482,9 @@ if (pPrefs->getPrefsValueBool((gchar*)AP_PREF_KEY_AutoGrammarCheck,&b)) _setGrammarCheck (b); + if (pPrefs->getPrefsValueBool((gchar*)XAP_PREF_KEY_SmartQuotesEnable,&b)) + _setSmartQuotes (b); + // ------------ Prefs _setPrefsAutoSave( pPrefs->getAutoSavePrefs() ); @@ -704,6 +713,8 @@ m_BOData[bo_CheckSpelling ].m_original = bValue; if (m_pPrefsScheme->getValueBool( AP_PREF_KEY_AutoGrammarCheck, &bValue)) m_BOData[bo_CheckGrammar ].m_original = bValue; + if (m_pPrefsScheme->getValueBool( XAP_PREF_KEY_SmartQuotesEnable, &bValue)) + m_BOData[bo_SmartQuotes ].m_original = bValue; if (m_pPrefsScheme->getValueBool( AP_PREF_KEY_CursorBlink, &bValue)) m_BOData[bo_CursorBlink ].m_original = bValue; if (m_pPrefsScheme->getValueBool(XAP_PREF_KEY_DirMarkerAfterClosingParenthesis, &bValue)) @@ -926,6 +937,10 @@ if (m_BOData[bo].m_current != m_BOData[bo].m_original) m_pPrefsScheme->setValueBool( AP_PREF_KEY_AutoGrammarCheck, m_BOData[bo].m_current); + bo = bo_SmartQuotes; + if (m_BOData[bo].m_current != m_BOData[bo].m_original) + m_pPrefsScheme->setValueBool( XAP_PREF_KEY_SmartQuotesEnable, m_BOData[bo].m_current); + bo = bo_CursorBlink; if (m_BOData[bo].m_current != m_BOData[bo].m_original) m_pPrefsScheme->setValueBool( AP_PREF_KEY_CursorBlink, m_BOData[bo].m_current); @@ -1145,6 +1160,7 @@ pScheme->getValueBool(XAP_PREF_KEY_AutoSaveFile, &(m_BOData[bo_AutoSave ].m_default)); pScheme->getValueBool( AP_PREF_KEY_AutoSpellCheck, &(m_BOData[bo_CheckSpelling ].m_default)); pScheme->getValueBool( AP_PREF_KEY_AutoGrammarCheck, &(m_BOData[bo_CheckGrammar ].m_default)); + pScheme->getValueBool( XAP_PREF_KEY_SmartQuotesEnable, &(m_BOData[bo_SmartQuotes ].m_default)); pScheme->getValueBool( AP_PREF_KEY_CursorBlink, &(m_BOData[bo_CursorBlink ].m_default)); pScheme->getValueBool(XAP_PREF_KEY_DirMarkerAfterClosingParenthesis, &(m_BOData[bo_DirectionMarkers ].m_default)); pScheme->getValueBool( AP_PREF_KEY_DefaultDirectionRtl, &(m_BOData[bo_DirectionRTL ].m_default)); Index: abiword-src/src/wp/ap/xp/ap_Dialog_Options.h =================================================================== --- abiword-src/src/wp/ap/xp/ap_Dialog_Options.h (.../http://svn.abisource.com/abiword/trunk) (revision 22791) +++ abiword-src/src/wp/ap/xp/ap_Dialog_Options.h (.../abiword-src) (working copy) @@ -57,6 +57,8 @@ id_BUTTON_SPELL_AUTOREPLACE, id_CHECK_GRAMMAR_CHECK, + id_CHECK_SMART_QUOTES_ENABLE, + id_CHECK_OTHER_DEFAULT_DIRECTION_RTL, id_CHECK_AUTO_SAVE_FILE, @@ -135,6 +137,7 @@ SET_GATHER (SpellUppercase, bool); SET_GATHER (SpellNumbers, bool); SET_GATHER (GrammarCheck, bool); + SET_GATHER (SmartQuotes, bool); SET_GATHER (PrefsAutoSave, bool); #if !defined (XP_UNIX_TARGET_GTK) && !defined(XP_TARGET_COCOA) @@ -236,6 +239,7 @@ bo_IgnoreUppercase, bo_IgnoreURLs, bo_CheckGrammar, + bo_SmartQuotes, bo_LayoutMarks, bo_MainDictionaryOnly, // NOT (YET?) IMPLEMENTED bo_Plugins,