1 /******************************************************************************** 2 * * 3 * M o d e l i n e P a r s e r * 4 * * 5 ********************************************************************************* 6 * Copyright (C) 2017,2021 by Jeroen van der Zijp. All Rights Reserved. * 7 ********************************************************************************* 8 * This program is free software: you can redistribute it and/or modify * 9 * it under the terms of the GNU General Public License as published by * 10 * the Free Software Foundation, either version 3 of the License, or * 11 * (at your option) any later version. * 12 * * 13 * This program is distributed in the hope that it will be useful, * 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 16 * GNU General Public License for more details. * 17 * * 18 * You should have received a copy of the GNU General Public License * 19 * along with this program. If not, see <http://www.gnu.org/licenses/>. * 20 ********************************************************************************/ 21 #ifndef MODELINE_H 22 #define MODELINE_H 23 24 25 // Parse modelines to set various editor attrubutes. 26 // Modelines are typically embedded in the first or last 27 // few lines of the document (inside comments so as to not 28 // interfere with compilers or interpreters). 29 class Modeline { 30 private: 31 FXString language; // Language 32 FXint autoindent; // Auto indent 33 FXint wrapwidth; // Wrap width 34 FXint tabwidth; // Tab stop columns 35 FXint wrapmode; // Wrap lines 36 FXint tabmode; // Tabs expanded into spaces 37 private: 38 FXbool parseVimModeline(const FXchar* s); 39 FXbool parseEmacsModeline(const FXchar* s); 40 FXbool parseAdieModeline(const FXchar* s); 41 public: 42 43 // Initialize 44 Modeline(); 45 46 // Parse mode line from character string 47 FXbool parseModeline(const FXchar* s); 48 49 // Parse mode line from string 50 FXbool parseModeline(const FXString& s); 51 52 // Access language name setLanguage(const FXString & n)53 void setLanguage(const FXString& n){ language=n; } getLanguage()54 const FXString& getLanguage() const { return language; } 55 56 // Access auto-indent setAutoIndent(FXint a)57 void setAutoIndent(FXint a){ autoindent=a; } getAutoIndent()58 FXint getAutoIndent() const { return autoindent; } 59 60 // Access wrap width setWrapWidth(FXint w)61 void setWrapWidth(FXint w){ wrapwidth=w; } getWrapWidth()62 FXint getWrapWidth() const { return wrapwidth; } 63 64 // Access tab width setTabWidth(FXint w)65 void setTabWidth(FXint w){ tabwidth=w; } getTabWidth()66 FXint getTabWidth() const { return tabwidth; } 67 68 // Access line wrap mode setWrapMode(FXint m)69 void setWrapMode(FXint m){ wrapmode=m; } getWrapMode()70 FXint getWrapMode() const { return wrapmode; } 71 72 // Access tab expand mode setTabMode(FXint m)73 void setTabMode(FXint m){ tabmode=m; } getTabMode()74 FXint getTabMode() const { return tabmode; } 75 76 // Clear for another call 77 void clear(); 78 }; 79 80 81 #endif 82