Revision: 706 http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=706&view=rev Author: frlan Date: 2009-06-11 21:30:17 +0000 (Thu, 11 Jun 2009)
Log Message: ----------- Merge geanyLaTeX plugin to geany-plugins project. Documentation still missing. Keeping separate plugin structure for future separate releases
Modified Paths: -------------- trunk/geany-plugins/po/POTFILES.in trunk/geany-plugins/wscript
Added Paths: ----------- trunk/geany-plugins/geanylatex/ trunk/geany-plugins/geanylatex/COPYING trunk/geany-plugins/geanylatex/ChangeLog trunk/geany-plugins/geanylatex/INSTALL trunk/geany-plugins/geanylatex/NEWS trunk/geany-plugins/geanylatex/TODO trunk/geany-plugins/geanylatex/src/ trunk/geany-plugins/geanylatex/src/bibtex.c trunk/geany-plugins/geanylatex/src/bibtex.h trunk/geany-plugins/geanylatex/src/bibtexlabels.c trunk/geany-plugins/geanylatex/src/datatypes.h trunk/geany-plugins/geanylatex/src/formatpatterns.c trunk/geany-plugins/geanylatex/src/formatutils.c trunk/geany-plugins/geanylatex/src/formatutils.h trunk/geany-plugins/geanylatex/src/geanylatex.c trunk/geany-plugins/geanylatex/src/geanylatex.h trunk/geany-plugins/geanylatex/src/latexencodings.c trunk/geany-plugins/geanylatex/src/latexencodings.h trunk/geany-plugins/geanylatex/src/latexenvironments.c trunk/geany-plugins/geanylatex/src/latexenvironments.h trunk/geany-plugins/geanylatex/src/latexkeybindings.c trunk/geany-plugins/geanylatex/src/latexkeybindings.h trunk/geany-plugins/geanylatex/src/latexutils.c trunk/geany-plugins/geanylatex/src/latexutils.h trunk/geany-plugins/geanylatex/src/letters.c trunk/geany-plugins/geanylatex/src/letters.h trunk/geany-plugins/geanylatex/src/reftex.c trunk/geany-plugins/geanylatex/src/reftex.h
Copied: trunk/geany-plugins/geanylatex/COPYING (from rev 705, trunk/geanylatex/COPYING) =================================================================== --- trunk/geany-plugins/geanylatex/COPYING (rev 0) +++ trunk/geany-plugins/geanylatex/COPYING 2009-06-11 21:30:17 UTC (rev 706) @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + <signature of Ty Coon>, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License.
Copied: trunk/geany-plugins/geanylatex/ChangeLog (from rev 705, trunk/geanylatex/ChangeLog) =================================================================== --- trunk/geany-plugins/geanylatex/ChangeLog (rev 0) +++ trunk/geany-plugins/geanylatex/ChangeLog 2009-06-11 21:30:17 UTC (rev 706) @@ -0,0 +1,188 @@ +2009-05-25 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> + + * Some more clean up of code. + * Update of documentation for 0.4 release. + + +2009-05-21 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> + + * Added configuration dialog. + + +2009-05-19 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> + + * Make toolbar document sensitive. + + +2009-05-17 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> + + * Adding some more items to toolbar for centerin, left and right formatted + text. Created LaTeX code based on needs still some improvement. Please + use with care. + + +2009-05-15 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> + + * Adding a toolbar for common LaTeX format topics. + + +2009-04-17 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> + + * Set undo points for better redo/undo on inserting formatings. + * Make reference type inside insert reference dialog accessible by + keyboard. + + +2009-04-12 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> + + * Added some new lines into latex beamer template. + + +2009-04-10 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> + + * Sort entries on insert reference dialog by alphabet. + + +2009-03-30 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> + + * Moved replacement functions into their own submenu. + * Added key bindings for formatting text with bold, italic and typewriter + font face. + + +2009-03-28 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> + + * Use a text field with pull down instead of a normal combo box for + font size at LaTeX wizard. + + +2009-03-27 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> + + * doc/geanylatex.tex: Added documentation written in LaTeX. + + +2009-03-20 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> + + * Replace \u-UTF-8 letters by octal coded chars. Huge thanks to + Dominic Hopf for providing patch and fighting that fight. + * Added a menu entry for bulk replace function and fixed a segfault at + replacing + + +2009-03-15 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> + + * Added a function to bulk replace special characters + inside marked text by keybinding + + +2009-03-13 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> + + * Don't offer insert environment dialog in case of no document is open. + + +2009-03-06 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> + + * Insert environment now supports selections by position \begin{} and + \end{} around + + +2009-02-28 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> + + * Don't react on some keybindings in case of no document is open. + * Added a feature for easy inserting environments to document. + * Added keybinding to insert \item into document. Very useful at + e.g. writing lists + + +2009-02-18 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> + + * Formating of selected text + * Added feature to replace special characters at input with LaTeX + replacment + + +2009-02-15 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> + + * Added a menu entry for easy formating of text + + +2009-02-15 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> + + * Release of GeanyLaTeX 0.3 + + +2009-02-14 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> + + * Added a keyboard shortcut for inserting a new line ( \ ). + * Make cursor placed behind inserted text for most cases. + (Inserting BibTeX entries will not reset the cursor) + + +2009-01-19 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> + + * Improved reference dialog to offer labels based on aux file + + +2008-11-17 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> + + * Added a submenu supporting inserting bibtex entries + + +2008-11-14 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> + + * Applied a patch by Enrico which corrects some spelling + mistakes and cleans up code a bit. + + +2008-11-02 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> + + * Make usage of Geany API v104 by using of Geany's plugin init + locale function. + + +2008-10-29 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> + + * GeanyLaTeX 0.2 release + + +2008-10-14 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> + + * Updated to Geany Plugin API v100 (add_document_sensitive()) + + +2008-09-01 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> + + * src/geanylatex.c: Added support for l10n. + + +2008-09-01 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> + + * Ported build system of spellcheck plugin. + + +2008-07-15 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> + + * Make plugin work together with Geany plugin API v78. + + +2008-07-11 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> + + * Make plugin compile with Geany svn r2767. + + +2008-06-26 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> + + * Update of used plugin API to v71. + + +2008-06-17 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de> + + * configure.in: + Fix build using autogen.sh (Makefile.in was not created). + * latexencodings.h: + Fix multiple definition of latex_encodings array. + + +2008-06-17 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> + + * Moved plugin to geany-plugin svn.
Copied: trunk/geany-plugins/geanylatex/INSTALL (from rev 705, trunk/geanylatex/INSTALL) =================================================================== --- trunk/geany-plugins/geanylatex/INSTALL (rev 0) +++ trunk/geany-plugins/geanylatex/INSTALL 2009-06-11 21:30:17 UTC (rev 706) @@ -0,0 +1,15 @@ +These installation instructions are written for a Linux system. + +At the time of this writing, building the plugin requires a recent SVN +checkout of the Geany sources (Geany Plugin API v130). + +You need for compliling the plugin the Geany header files installed. +For configuring and installing just run + + % configure + % make + % make install + +If you want to install geanyLaTeX to another directory, you should run +configure with --prefix=/path/to/dir option. make install will install +all files to your new target.
Copied: trunk/geany-plugins/geanylatex/NEWS (from rev 705, trunk/geanylatex/NEWS) =================================================================== --- trunk/geany-plugins/geanylatex/NEWS (rev 0) +++ trunk/geany-plugins/geanylatex/NEWS 2009-06-11 21:30:17 UTC (rev 706) @@ -0,0 +1 @@ +Please check ChangeLog for details. \ No newline at end of file
Copied: trunk/geany-plugins/geanylatex/TODO (from rev 705, trunk/geanylatex/TODO) =================================================================== --- trunk/geany-plugins/geanylatex/TODO (rev 0) +++ trunk/geany-plugins/geanylatex/TODO 2009-06-11 21:30:17 UTC (rev 706) @@ -0,0 +1,16 @@ + TODO +************ + +* Improving support for bibTeX + * Parsing of *.bib + * Inserting of \cite + * Dialog for inserting bibTeX entries +* Wizard: + * Adding support for diff. letter classes + * Make plugin use customisable templates +* Replacing of environments +* Parsing document for »TOC« + * Navigation throught document + * "Graphical" support while using \ref, \pageref ... +* Code examples for very common problems +* Make special characters extensible through files
Copied: trunk/geany-plugins/geanylatex/src/bibtex.c (from rev 705, trunk/geanylatex/src/bibtex.c) =================================================================== --- trunk/geany-plugins/geanylatex/src/bibtex.c (rev 0) +++ trunk/geany-plugins/geanylatex/src/bibtex.c 2009-06-11 21:30:17 UTC (rev 706) @@ -0,0 +1,141 @@ +/* + * bibtex.c + * + * Copyright 2008-2009 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#include "bibtex.h" +#include "reftex.h" + +#define glatex_set_status(entry_number, flag) \ + fields[entry_number] = flag; + + +#if 0 +static int get_entry_pos(char *str) +{ + int i; + + if(str != NULL) { + for (i = 0; i < N_ENTRIES; i++) { + if (utils_str_casecmp(str, label_entry[i]) == 0) + return i; + } + } + return -1; +} +#endif + +void glatex_insert_bibtex_entry(G_GNUC_UNUSED GtkMenuItem * menuitem, + G_GNUC_UNUSED gpointer gdata) +{ + int doctype = GPOINTER_TO_INT(gdata); + gboolean fields[N_ENTRIES]; + gchar *output = g_strdup("@"); + int i; + + for (i = 0; i < N_ENTRIES; i++) + { + glatex_set_status(i, FALSE); + } + + switch(doctype) { + case ARTICLE: + glatex_set_status(AUTHOR, TRUE); + glatex_set_status(TITLE, TRUE); + glatex_set_status(JOURNAL, TRUE); + glatex_set_status(YEAR, TRUE); + break; + case BOOK: + glatex_set_status(AUTHOR, TRUE); + glatex_set_status(EDITOR, TRUE); + glatex_set_status(TITLE, TRUE); + glatex_set_status(PUBLISHER, TRUE); + glatex_set_status(YEAR, TRUE); + break; + case BOOKLET: + glatex_set_status(TITLE, TRUE); + break; + case CONFERENCE: + case INCOLLECTION: + case INPROCEEDINGS: + glatex_set_status(AUTHOR, TRUE); + glatex_set_status(TITLE, TRUE); + glatex_set_status(BOOKTITLE, TRUE); + glatex_set_status(YEAR, TRUE); + break; + case INBOOK: + glatex_set_status(AUTHOR, TRUE); + glatex_set_status(EDITOR, TRUE); + glatex_set_status(TITLE, TRUE); + glatex_set_status(CHAPTER, TRUE); + glatex_set_status(PAGES, TRUE); + glatex_set_status(PUBLISHER, TRUE); + glatex_set_status(YEAR, TRUE); + break; + case MANUAL: + glatex_set_status(TITLE, TRUE); + break; + case MASTERSTHESIS: + case PHDTHESIS: + glatex_set_status(AUTHOR, TRUE); + glatex_set_status(TITLE, TRUE); + glatex_set_status(SCHOOL, TRUE); + glatex_set_status(YEAR, TRUE); + break; + case MISC: + for (i = 0; i < N_ENTRIES; i++) + { + glatex_set_status(i, TRUE); + } + case TECHREPORT: + glatex_set_status(AUTHOR, TRUE); + glatex_set_status(TITLE, TRUE); + glatex_set_status(INSTITUTION, TRUE); + glatex_set_status(YEAR, TRUE); + break; + case UNPUBLISHED: + glatex_set_status(AUTHOR, TRUE); + glatex_set_status(TITLE, TRUE); + glatex_set_status(NOTE, TRUE); + break; + case PROCEEDINGS: + glatex_set_status(TITLE, TRUE); + glatex_set_status(YEAR, TRUE); + break; + default: + for (i = 0; i < N_ENTRIES; i++) + { + glatex_set_status(i, TRUE); + } + } + + output = g_strconcat(output, glatex_label_types[doctype], "{ \n",NULL); + for (i = 0; i < N_ENTRIES; i++) + { + if (fields[i] == TRUE) + { + output = g_strconcat(output, glatex_label_entry_keywords[i], " = {},\n", NULL); + } + } + + output = g_strconcat(output, "}\n", NULL); + glatex_insert_string(output, FALSE); + + g_free(output); +}
Copied: trunk/geany-plugins/geanylatex/src/bibtex.h (from rev 705, trunk/geanylatex/src/bibtex.h) =================================================================== --- trunk/geany-plugins/geanylatex/src/bibtex.h (rev 0) +++ trunk/geany-plugins/geanylatex/src/bibtex.h 2009-06-11 21:30:17 UTC (rev 706) @@ -0,0 +1,91 @@ + /* + * bibtex.h + * + * Copyright 2008 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#ifndef LATEXBIBTEX_H +#define LATEXBIBTEX_H + +#include "geanylatex.h" + + +/* Define generic stuff */ +enum { + ARTICLE = 0, + BOOK, + BOOKLET, + CONFERENCE, + INBOOK, + INCOLLECTION, + INPROCEEDINGS, + MANUAL, + MASTERSTHESIS, + MISC, + PHDTHESIS, + PROCEEDINGS, + TECHREPORT, + UNPUBLISHED, + N_TYPES +}; + + +enum { + ADDRESS = 0, + ANNOTE, + AUTHOR, + BOOKTITLE, + CHAPTER, + CROSSREF, + EDITION, + EDITOR, + EPRINT, + HOWPUBLISHED, + INSTITUTION, + JOURNAL, + KEY, + MONTH, + NOTE, + NUMBER, + ORGANIZATION, + PAGES, + PUBLISHER, + SCHOOL, + SERIES, + TITLE, + TYPE, + URL, + VOLUME, + YEAR, + N_ENTRIES +}; + +extern gchar *glatex_label_types[]; + +extern const gchar *glatex_label_tooltips[]; + +extern const gchar *glatex_label_entry_keywords[]; + +extern const gchar *glatex_label_entry[]; + +int glatex_push_bibtex_entry(int style, GeanyDocument *doc); + +void glatex_insert_bibtex_entry(G_GNUC_UNUSED GtkMenuItem * menuitem, + G_GNUC_UNUSED gpointer gdata); + +#endif
Copied: trunk/geany-plugins/geanylatex/src/bibtexlabels.c (from rev 705, trunk/geanylatex/src/bibtexlabels.c) =================================================================== --- trunk/geany-plugins/geanylatex/src/bibtexlabels.c (rev 0) +++ trunk/geany-plugins/geanylatex/src/bibtexlabels.c 2009-06-11 21:30:17 UTC (rev 706) @@ -0,0 +1,126 @@ + /* + * bibtexlabels.c + * + * Copyright 2009 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#include "geanylatex.h" +#include "bibtex.h" + +gchar *glatex_label_types[] = { + N_("Article"), + N_("Book"), + N_("Booklet"), + N_("Conference"), + N_("Inbook"), + N_("Incollection"), + N_("Inproceedings"), + N_("Manual"), + N_("Mastersthesis"), + N_("Misc"), + N_("PhdThesis"), + N_("Proceedings"), + N_("Techreport"), + N_("Unpublished")}; + + +const gchar *glatex_label_entry[] = { + N_("Address"), + N_("Annote"), + N_("Author"), + N_("Booktitle"), + N_("Chapter"), + N_("Crossref"), + N_("Edition"), + N_("Editor"), + N_("E-print"), + N_("HowPublished"), + N_("Institution"), + N_("Journal"), + N_("Key"), + N_("Month"), + N_("Note"), + N_("Number"), + N_("Organization"), + N_("Pages"), + N_("Publisher"), + N_("School"), + N_("Series"), + N_("Title"), + N_("Type"), + N_("URL"), + N_("Volume"), + N_("Year")}; + +const gchar *glatex_label_entry_keywords[] = { + ("Address"), + ("Annote"), + ("Author"), + ("Booktitle"), + ("Chapter"), + ("Crossref"), + ("Edition"), + ("Editor"), + ("E-print"), + ("HowPublished"), + ("Institution"), + ("Journal"), + ("Key"), + ("Month"), + ("Note"), + ("Number"), + ("Organization"), + ("Pages"), + ("Publisher"), + ("School"), + ("Series"), + ("Title"), + ("Type"), + ("URL"), + ("Volume"), + ("Year")}; + +const gchar *glatex_label_tooltips[] = { + N_("Address of publisher"), + N_("Annotation for annotated bibliography styles"), + N_("Name(s) of the author(s), separated by 'and' if more than one"), + N_("Title of the book, if only part of it is being cited"), + N_("Chapter number"), + N_("Citation key of the cross-referenced entry"), + N_("Edition of the book (such as "first" or "second")"), + N_("Name(s) of the editor(s), separated by 'and' if more than one"), + N_("Specification of electronic publication"), + N_("Publishing method if the method is nonstandard"), + N_("Institution that was involved in the publishing"), + N_("Journal or magazine in which the work was published"), + N_("Hidden field used for specifying or overriding the alphabetical order of entries"), + N_("Month of publication or creation if unpublished"), + N_("Miscellaneous extra information"), + N_("Number of journal, magazine, or tech-report"), + N_("Sponsor of the conference"), + N_("Page numbers separated by commas or double-hyphens"), + N_("Name of publisher"), + N_("School where thesis was written"), + N_("Series of books in which the book was published"), + N_("Title of the work"), + N_("Type of technical report"), + N_("Internet address"), + N_("Number of the volume"), + N_("Year of publication or creation if unpublished")}; + +
Copied: trunk/geany-plugins/geanylatex/src/datatypes.h (from rev 705, trunk/geanylatex/src/datatypes.h) =================================================================== --- trunk/geany-plugins/geanylatex/src/datatypes.h (rev 0) +++ trunk/geany-plugins/geanylatex/src/datatypes.h 2009-06-11 21:30:17 UTC (rev 706) @@ -0,0 +1,40 @@ +/* + * datatypes.h + * + * Copyright 2008 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#ifndef DATATYPES_H +#define DATATYPES_H + +typedef struct +{ + gint cat; + gchar *label; + gchar *latex; +} SubMenuTemplate; + + +typedef struct +{ + gint cat; + gchar *label; + gboolean sorted; +} CategoryName; + +#endif
Copied: trunk/geany-plugins/geanylatex/src/formatpatterns.c (from rev 705, trunk/geanylatex/src/formatpatterns.c) =================================================================== --- trunk/geany-plugins/geanylatex/src/formatpatterns.c (rev 0) +++ trunk/geany-plugins/geanylatex/src/formatpatterns.c 2009-06-11 21:30:17 UTC (rev 706) @@ -0,0 +1,48 @@ +/* + * formatpatterns.c + * + * Copyright 2009 Frank Lanitz frank@Jupiter + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#include "geanylatex.h" + +gchar* glatex_format_pattern[] = { + "\textit", + "\textbf", + "\underline", + "\textsl", + "\texttt", + "\textsc", + "\emph", + "\centering", + "\raggedleft", + "\raggedright", +}; + +const gchar *glatex_format_labels[] = { + N_("Italic"), + N_("Boldfont"), + N_("Underline"), + N_("Slanted"), + N_("Typewriter"), + N_("Small Caps"), + N_("Emphasis"), + N_("Centered"), + N_("Left side oriented"), + N_("Right side oriented") +};
Copied: trunk/geany-plugins/geanylatex/src/formatutils.c (from rev 705, trunk/geanylatex/src/formatutils.c) =================================================================== --- trunk/geany-plugins/geanylatex/src/formatutils.c (rev 0) +++ trunk/geany-plugins/geanylatex/src/formatutils.c 2009-06-11 21:30:17 UTC (rev 706) @@ -0,0 +1,58 @@ +/* + * formatutils.c + * + * Copyright 2009 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#include "formatutils.h" + + +void glatex_insert_latex_format(G_GNUC_UNUSED GtkMenuItem * menuitem, + G_GNUC_UNUSED gpointer gdata) +{ + gint format = GPOINTER_TO_INT(gdata); + GeanyDocument *doc = NULL; + doc = document_get_current(); + + if (doc != NULL) + { + if (sci_has_selection(doc->editor->sci)) + { + gchar *selection; + const gchar *replacement = NULL; + + selection = sci_get_selection_contents(doc->editor->sci); + + replacement = g_strconcat(glatex_format_pattern[format],"{", + selection, "}", NULL); + + sci_replace_sel(doc->editor->sci, replacement); + g_free(selection); + } + else + { + sci_start_undo_action(doc->editor->sci); + glatex_insert_string(glatex_format_pattern[format], TRUE); + glatex_insert_string("{", TRUE); + glatex_insert_string("}", FALSE); + sci_end_undo_action(doc->editor->sci); + } + } +} + +
Copied: trunk/geany-plugins/geanylatex/src/formatutils.h (from rev 705, trunk/geanylatex/src/formatutils.h) =================================================================== --- trunk/geany-plugins/geanylatex/src/formatutils.h (rev 0) +++ trunk/geany-plugins/geanylatex/src/formatutils.h 2009-06-11 21:30:17 UTC (rev 706) @@ -0,0 +1,45 @@ +/* + * formatutils.h + * + * Copyright 2009 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#ifndef LATEXFORMATUTILS_H +#define LATEXFORMATUTILS_H + +#include "geanylatex.h" + +enum { + LATEX_ITALIC = 0, + LATEX_BOLD, + LATEX_UNDERLINE, + LATEX_SLANTED, + LATEX_TYPEWRITER, + LATEX_SMALLCAPS, + LATEX_EMPHASIS, + LATEX_CENTER, + LATEX_LEFT, + LATEX_RIGHT, + LATEX_STYLES_END +}; + +extern gchar* glatex_format_pattern[]; +extern const gchar *glatex_format_labels[]; +void glatex_insert_latex_format(GtkMenuItem * menuitem, gpointer gdata); + +#endif
Copied: trunk/geany-plugins/geanylatex/src/geanylatex.c (from rev 705, trunk/geanylatex/src/geanylatex.c) =================================================================== --- trunk/geany-plugins/geanylatex/src/geanylatex.c (rev 0) +++ trunk/geany-plugins/geanylatex/src/geanylatex.c 2009-06-11 21:30:17 UTC (rev 706) @@ -0,0 +1,1309 @@ +/* + * geanylatex.c - Plugin to let Geany better work together with LaTeX + * + * Copyright 2007-2009 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> + * For long list of friendly supporters please have a look at THANKS. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/* LaTeX plugin */ +/* This plugin improves the work with LaTeX and Geany.*/ + +#include "geanylatex.h" + +PLUGIN_VERSION_CHECK(136) + +PLUGIN_SET_INFO(_("LaTeX"), _("Plugin to provide better LaTeX support"), + VERSION,"Frank Lanitz frank@frank.uvena.de") + +GeanyPlugin *geany_plugin; +GeanyData *geany_data; +GeanyFunctions *geany_functions; + + +static GtkWidget *menu_latex = NULL; +static GtkWidget *menu_latex_menu = NULL; +static GtkWidget *menu_latex_wizzard = NULL; +static GtkWidget *menu_latex_menu_special_char = NULL; +static GtkWidget *menu_latex_menu_special_char_submenu = NULL; +static GtkWidget *menu_latex_ref = NULL; +static GtkWidget *menu_latex_label = NULL; +static GtkWidget *menu_latex_bibtex = NULL; +static GtkWidget *menu_latex_bibtex_submenu = NULL; +static GtkWidget *menu_latex_format_insert = NULL; +static GtkWidget *menu_latex_format_insert_submenu = NULL; +static GtkWidget *menu_latex_insert_environment = NULL; +static GtkWidget *menu_latex_replacement = NULL; +static GtkWidget *menu_latex_replacement_submenu = NULL; +static GtkWidget *menu_latex_replace_selection = NULL; +static GtkWidget *menu_latex_replace_toggle = NULL; + +/* Options for plugin */ +static gboolean glatex_set_koma_active = FALSE; +static gboolean glatex_set_toolbar_active = FALSE; + +/* Function will be deactivated, when only loaded */ +static gboolean toggle_active = FALSE; + +static GtkWidget *main_menu_item = NULL; + +static GtkUIManager *uim; +static GtkActionGroup *group; +static GtkWidget *glatex_toolbar = NULL; +static GtkWidget *box = NULL; + +/* Configuration file */ +static gchar *config_file = NULL; + +/* Doing some basic keybinding stuff */ +enum +{ + KB_LATEX_WIZZARD, + KB_LATEX_INSERT_LABEL, + KB_LATEX_INSERT_REF, + KB_LATEX_INSERT_NEWLINE, + KB_LATEX_TOGGLE_ACTIVE, + KB_LATEX_ENVIRONMENT_INSERT, + KB_LATEX_INSERT_NEWITEM, + KB_LATEX_REPLACE_SPECIAL_CHARS, + KB_LATEX_FORMAT_BOLD, + KB_LATEX_FORMAT_ITALIC, + KB_LATEX_FORMAT_TYPEWRITER, + KB_LATEX_FORMAT_CENTER, + KB_LATEX_FORMAT_LEFT, + KB_LATEX_FORMAT_RIGHT, + COUNT_KB +}; + +PLUGIN_KEY_GROUP(geanylatex, COUNT_KB) + +const GtkActionEntry format_icons[] = +{ + { "Italic", GTK_STOCK_ITALIC, NULL, NULL, N_("Marks selected text as italic"), G_CALLBACK(glatex_kb_format_bold) }, + { "Bold", GTK_STOCK_BOLD, NULL, NULL, N_("Marks selected text as bold"), G_CALLBACK(glatex_kb_format_bold) }, + { "Underline", GTK_STOCK_UNDERLINE, NULL, NULL, N_("Underlines selected text"), G_CALLBACK(glatex_kb_format_bold) }, + { "Centered", GTK_STOCK_JUSTIFY_CENTER, NULL, NULL, NULL, G_CALLBACK(glatex_kb_format_centering) }, + { "Left", GTK_STOCK_JUSTIFY_LEFT, NULL, NULL, NULL, G_CALLBACK(glatex_kb_format_left) }, + { "Right", GTK_STOCK_JUSTIFY_RIGHT, NULL, NULL, NULL, G_CALLBACK(glatex_kb_format_right) }, +}; + +const guint ui_entries_n = G_N_ELEMENTS(format_icons); + + +/* fallback UI definition */ +const gchar *toolbar_markup = +"<ui>" + "<toolbar name='glatex_format_toolbar'>" + "<toolitem action='Italic'/>" + "<toolitem action='Bold'/>" + "<toolitem action='Underline'/>" + "<separator/>" + "<toolitem action='Centered' />" + "<toolitem action='Left' />" + "<toolitem action='Right'/>" + "</toolbar>" +"</ui>"; + +static struct +{ + GtkWidget *koma_active; + GtkWidget *toolbar_active; +} +config_widgets; + + +static GtkWidget *init_toolbar() +{ + GtkWidget *toolbar = NULL; + + box = ui_lookup_widget(geany->main_widgets->window, "vbox1"); + uim = gtk_ui_manager_new(); + group = gtk_action_group_new("glatex_format_toolbar"); + gtk_action_group_set_translation_domain(group, GETTEXT_PACKAGE); + gtk_action_group_add_actions(group, format_icons, ui_entries_n, NULL); + gtk_ui_manager_insert_action_group(uim, group, 0); + if (gtk_ui_manager_add_ui_from_string(uim, toolbar_markup, -1, NULL) > 0) + { + toolbar = gtk_ui_manager_get_widget(uim, "/ui/glatex_format_toolbar"); + gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(toolbar), FALSE, TRUE, 0); + gtk_box_reorder_child(GTK_BOX(box), toolbar, 2); + ui_add_document_sensitive(toolbar); + } + /* TODO maybe more error handling */ + + return toolbar; +} + + +static void +on_configure_response(G_GNUC_UNUSED GtkDialog *dialog, gint response, + G_GNUC_UNUSED gpointer user_data) +{ + if (response == GTK_RESPONSE_OK || response == GTK_RESPONSE_APPLY) + { + GKeyFile *config = g_key_file_new(); + gchar *data; + gchar *config_dir = g_path_get_dirname(config_file); + + config_file = g_strconcat(geany->app->configdir, + G_DIR_SEPARATOR_S, "plugins", G_DIR_SEPARATOR_S, + "geanyLaTeX", G_DIR_SEPARATOR_S, "general.conf", NULL); + glatex_set_koma_active = + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(config_widgets.koma_active)); + glatex_set_toolbar_active = + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(config_widgets.toolbar_active)); + + /* write stuff to file */ + g_key_file_load_from_file(config, config_file, G_KEY_FILE_NONE, NULL); + + g_key_file_set_boolean(config, "general", "glatex_set_koma_active", + glatex_set_koma_active); + g_key_file_set_boolean(config, "general", "glatex_set_toolbar_active", + glatex_set_toolbar_active); + + if (!g_file_test(config_dir, G_FILE_TEST_IS_DIR) + && utils_mkdir(config_dir, TRUE) != 0) + { + dialogs_show_msgbox(GTK_MESSAGE_ERROR, + _("Plugin configuration directory could not be created.")); + } + else + { + /* write config to file */ + data = g_key_file_to_data(config, NULL, NULL); + utils_write_file(config_file, data); + g_free(data); + } + + g_free(config_dir); + g_key_file_free(config); + + /* Apply changes to Geany */ + /* Add toolbar if requested */ + if (glatex_set_toolbar_active == TRUE) + { + if (glatex_toolbar == NULL) + { + glatex_toolbar = init_toolbar(); + } + else + { + gtk_widget_show(glatex_toolbar); + } + } + /* Hide toolbar */ + else if (glatex_set_toolbar_active == FALSE && glatex_toolbar != NULL) + { + gtk_widget_hide(glatex_toolbar); + } + } +} + +GtkWidget * +plugin_configure(GtkDialog * dialog) +{ + GtkWidget *vbox; + + vbox = gtk_vbox_new(FALSE, 6); + + config_widgets.koma_active = gtk_check_button_new_with_label( + _("Use KOMA script by default")); + config_widgets.toolbar_active = gtk_check_button_new_with_label( + _("Show extra plugin toolbar")); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(config_widgets.koma_active), + glatex_set_koma_active); + gtk_box_pack_start(GTK_BOX(vbox), config_widgets.koma_active, FALSE, FALSE, 2); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(config_widgets.toolbar_active), + glatex_set_toolbar_active); + gtk_box_pack_start(GTK_BOX(vbox), config_widgets.toolbar_active, FALSE, FALSE, 2); + + gtk_widget_show_all(vbox); + g_signal_connect(dialog, "response", G_CALLBACK(on_configure_response), NULL); + return vbox; +} + +/* Functions to toggle the status of plugin */ +void glatex_set_latextoggle_status(gboolean new_status) +{ + /* No more function at the moment.*/ + if (toggle_active != new_status) + toggle_active = new_status; +} + +void glatex_toggle_status(G_GNUC_UNUSED GtkMenuItem * menuitem) +{ + if (toggle_active == TRUE) + glatex_set_latextoggle_status(FALSE); + else + glatex_set_latextoggle_status(TRUE); +} + + +static gboolean ht_editor_notify_cb(G_GNUC_UNUSED GObject *object, GeanyEditor *editor, + SCNotification *nt, G_GNUC_UNUSED gpointer data) +{ + g_return_val_if_fail(editor != NULL, FALSE); + + if (toggle_active != TRUE) + return FALSE; + + if (nt->nmhdr.code == SCN_CHARADDED) + { + gchar buf[7]; + gint len; + + len = g_unichar_to_utf8(nt->ch, buf); + if (len > 0) + { + const gchar *entity; + + buf[len] = '\0'; + entity = glatex_get_entity(buf); + + if (entity != NULL) + { + gint pos = sci_get_current_position(editor->sci); + + sci_set_selection_start(editor->sci, pos - len); + sci_set_selection_end(editor->sci, pos); + + sci_replace_sel(editor->sci, entity); + } + } + } + return FALSE; +} + + +void glatex_replace_special_character() +{ + GeanyDocument *doc = NULL; + doc = document_get_current(); + + if (doc != NULL && sci_has_selection(doc->editor->sci)) + { + guint selection_len; + gchar *selection = NULL; + GString *replacement = g_string_new(NULL); + guint i; + gchar *new = NULL; + const gchar *entity = NULL; + gchar buf[7]; + gint len; + + selection = sci_get_selection_contents(doc->editor->sci); + + selection_len = strlen(selection); + + for (i = 0; i < selection_len; i++) + { + len = g_unichar_to_utf8(g_utf8_get_char(selection + i), buf); + i = len - 1 + i; + buf[len] = '\0'; + entity = glatex_get_entity(buf); + + if (entity != NULL) + { + replacement = g_string_append(replacement, entity); + } + else + { + replacement = g_string_append(replacement, buf); + } + } + new = g_string_free(replacement, FALSE); + sci_replace_sel(doc->editor->sci, new); + g_free(selection); + g_free(new); + } +} + +/* Called when keys were pressed */ +void glatex_kblatex_toggle(G_GNUC_UNUSED guint key_id) +{ + if (toggle_active == TRUE) + glatex_set_latextoggle_status(FALSE); + else + glatex_set_latextoggle_status(TRUE); +} + + +PluginCallback plugin_callbacks[] = +{ + { "editor-notify", (GCallback) &ht_editor_notify_cb, FALSE, NULL }, + { NULL, NULL, FALSE, NULL } +}; + +void +glatex_insert_string(gchar *string, gboolean reset_position) +{ + GeanyDocument *doc = NULL; + + doc = document_get_current(); + + if (doc != NULL && string != NULL) + { + gint pos = sci_get_current_position(doc->editor->sci); + sci_insert_text(doc->editor->sci, pos, string); + if (reset_position == TRUE) + { + gint len = strlen(string); + sci_set_current_position(doc->editor->sci, pos + len, TRUE); + } + } +} + + +inline gchar* +get_latex_command(gint tab_index) +{ + return glatex_char_array[tab_index].latex; +} + + +static void +char_insert_activated(G_GNUC_UNUSED GtkMenuItem * menuitem, + G_GNUC_UNUSED gpointer gdata) +{ + glatex_insert_string(get_latex_command(GPOINTER_TO_INT(gdata)), TRUE); +} + + +void +glatex_insert_label_activated(G_GNUC_UNUSED GtkMenuItem * menuitem, + G_GNUC_UNUSED gpointer gdata) +{ + GtkWidget *dialog = NULL; + GtkWidget *vbox = NULL; + GtkWidget *label = NULL; + GtkWidget *textbox_label = NULL; + GtkWidget *table = NULL; + + dialog = gtk_dialog_new_with_buttons(_("Insert Label"), + GTK_WINDOW(geany->main_widgets->window), + GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, + GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, + NULL); + vbox = ui_dialog_vbox_new(GTK_DIALOG(dialog)); + gtk_widget_set_name(dialog, "GeanyDialog"); + gtk_box_set_spacing(GTK_BOX(vbox), 10); + + table = gtk_table_new(1, 2, FALSE); + gtk_table_set_col_spacings(GTK_TABLE(table), 6); + gtk_table_set_row_spacings(GTK_TABLE(table), 6); + + label = gtk_label_new(_("Label name:")); + textbox_label = gtk_entry_new(); + + gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); + + gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); + gtk_table_attach_defaults(GTK_TABLE(table), textbox_label, 1, 2, 0, 1); + gtk_container_add(GTK_CONTAINER(vbox), table); + + gtk_widget_show_all(vbox); + + if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) + { + gchar *label_str = NULL; + label_str = g_strconcat("\label{",g_strdup(gtk_entry_get_text( + GTK_ENTRY(textbox_label))), "}", NULL); + glatex_insert_string(label_str, TRUE); + } + + gtk_widget_destroy(dialog); +} + + +void +glatex_insert_ref_activated(G_GNUC_UNUSED GtkMenuItem * menuitem, + G_GNUC_UNUSED gpointer gdata) +{ + GtkWidget *dialog; + GtkWidget *vbox = NULL; + GtkWidget *label_ref = NULL; + GtkWidget *textbox_ref = NULL; + GtkWidget *table = NULL; + GtkWidget *radio1 = NULL; + GtkWidget *radio2 = NULL; + GtkTreeModel *model = NULL; + + + dialog = gtk_dialog_new_with_buttons(_("Insert Reference"), + GTK_WINDOW(geany->main_widgets->window), + GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, + GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, + NULL); + vbox = ui_dialog_vbox_new(GTK_DIALOG(dialog)); + gtk_widget_set_name(dialog, "GeanyDialog"); + gtk_box_set_spacing(GTK_BOX(vbox), 10); + + table = gtk_table_new(1, 2, FALSE); + gtk_table_set_col_spacings(GTK_TABLE(table), 6); + gtk_table_set_row_spacings(GTK_TABLE(table), 6); + + label_ref = gtk_label_new(_("Reference name:")); + textbox_ref = gtk_combo_box_entry_new_text(); + glatex_add_Labels(textbox_ref, glatex_get_aux_file()); + model = gtk_combo_box_get_model(GTK_COMBO_BOX(textbox_ref)); + gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(model), + 0, GTK_SORT_ASCENDING); + + gtk_misc_set_alignment(GTK_MISC(label_ref), 0, 0.5); + + gtk_table_attach_defaults(GTK_TABLE(table), label_ref, 0, 1, 0, 1); + gtk_table_attach_defaults(GTK_TABLE(table), textbox_ref, 1, 2, 0, 1); + gtk_container_add(GTK_CONTAINER(vbox), table); + + radio1 = gtk_radio_button_new_with_mnemonic(NULL, + _("_Standard Reference")); + gtk_button_set_focus_on_click(GTK_BUTTON(radio1), FALSE); + gtk_container_add(GTK_CONTAINER(vbox), radio1); + + radio2 = gtk_radio_button_new_with_mnemonic_from_widget(GTK_RADIO_BUTTON(radio1), + _("_Page Reference")); + gtk_button_set_focus_on_click(GTK_BUTTON(radio2), FALSE); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio2), FALSE); + gtk_container_add(GTK_CONTAINER(vbox), radio2); + + gtk_widget_show_all(vbox); + + + if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) + { + gchar *ref_string = NULL; + + ref_string = g_strdup(gtk_combo_box_get_active_text( + GTK_COMBO_BOX(textbox_ref))); + + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radio2)) == FALSE) + { + ref_string = g_strconcat("\ref{", ref_string, "}", NULL); + } + else + { + ref_string = g_strconcat("\pageref{", ref_string, "}", NULL); + } + + if (ref_string != NULL) + { + glatex_insert_string(ref_string, TRUE); + g_free(ref_string); + } + } + + gtk_widget_destroy(dialog); +} + + +void glatex_character_create_menu_item(GtkWidget *menu, const gchar *label, + gint letter, MenuCallback callback) +{ + GtkWidget *tmp; + + tmp = gtk_menu_item_new_with_label(label); + gtk_widget_show(tmp); + gtk_container_add(GTK_CONTAINER(menu), tmp); + g_signal_connect(tmp, "activate", + G_CALLBACK(callback), GINT_TO_POINTER(letter)); +} + + +/* returns -1, if there are more than gint can work with or any other error + * returns 0, if categorie is empty + * if gint categorie is -1, function will count every element. + * Useful, if there is no need for a categorie check.*/ +gint +glatex_count_menu_entries(SubMenuTemplate *tmp, gint categorie) +{ + /* TODO: Reset max value to stop before it's too late */ + gint i; + gint count = 0; + + if (categorie == -1) + { + for (i =1; tmp[i].label != NULL; i++) + { + count = count + 1; + } + } + else + { + for (i = 1; tmp[i].label != NULL; i++) + { + if (tmp[i].cat == categorie) + { + count = count + 1; + } + if (i >= 256) + { + count = -1; + break; + } + } + } + return count + 1; +} + +static gint +count_menu_cat_entries(CategoryName *tmp) +{ + gint i; + + for (i = 0; tmp[i].label != NULL; i++); + return i; +} + + +void glatex_sub_menu_init(GtkWidget *base_menu, SubMenuTemplate *menu_template, + CategoryName *category_name, + MenuCallback callback_function) +{ + gint i; + gint j; + gint categories = count_menu_cat_entries(category_name); + GtkWidget *sub_menu = NULL; + GtkWidget *sub_menu_cat[categories][2]; + GtkWidget *active_submenu = NULL; + + /* Creates sub menus based on information from letter.h */ + for (i = 0; i < categories; i++) + { + if (glatex_count_menu_entries(menu_template, i) > 0) + { + create_sub_menu(base_menu, sub_menu_cat[i][0], + sub_menu_cat[i][1], category_name[i].label); + } + } + + /* Searching for all categories */ + for (i = 0; i < categories; i++) + { + gboolean split = FALSE; + gboolean last_sub_menu = FALSE; + gboolean sorted = category_name[i].sorted; + /* To check whether we need to build up a new sub sub menu. */ + gint local_count = 0; + gint item_count = glatex_count_menu_entries(menu_template, i); + + if (item_count < 1) + continue; + + /* Default is, not to split anything to make menu not */ + /* deeper than realy needed. */ + if (item_count > MAX_MENU_ENTRIES) + { + split = TRUE; + } + + /* Setting active sub menu to sub menu of category */ + sub_menu = sub_menu_cat[i][0]; + active_submenu = sub_menu; + /* Finding entries for each category */ + + for (j = 0; menu_template[j].latex != NULL; j++) + { + if (menu_template[j].cat == i) + { + /* Creates a new sub sub menu if needed */ + if (split == TRUE && (local_count % MAX_MENU_ENTRIES) == 0) + { + gint next_split_point = 0; + GtkWidget *tmp = NULL; + GtkWidget *tmp_item = NULL; + + sub_menu = active_submenu; + + for (next_split_point = 0; + next_split_point < MAX_MENU_ENTRIES ; next_split_point ++) + { + if (menu_template[j+next_split_point].cat != i) + { + last_sub_menu = TRUE; + break; + } + + } + + if (sorted == TRUE) + { + create_sub_menu(sub_menu_cat[i][0], tmp, tmp_item, + g_strconcat(menu_template[j].label, " ... ", + menu_template[j + next_split_point-1].label, NULL)); + + sub_menu = tmp; + } + else if (sorted == FALSE) + { + if (last_sub_menu == FALSE) + { + create_sub_menu(sub_menu, tmp, tmp_item, _("More")); + sub_menu = active_submenu; + active_submenu = tmp; + } + } + } + + /* Sets the counter to keep in track if a new ,, + * submenu needs to be build up */ + local_count = local_count + 1; + glatex_character_create_menu_item(sub_menu, g_strconcat( + menu_template[j].label, "\t", menu_template[j].latex, + NULL), j, callback_function); + } + } + } +} + +static int +find_latex_enc(gint l_geany_enc) +{ + guint i; + for (i = 0; i < LATEX_ENCODINGS_MAX; i++) + { + if (latex_encodings[i].geany_enc == l_geany_enc) + return i; + } + return LATEX_ENCODING_NONE; +} + + +static void +show_output(const gchar * output, const gchar * name, const gint local_enc) +{ + GeanyDocument *doc = NULL; + GeanyFiletype *ft = filetypes_lookup_by_name("LaTeX"); + + if (output) + { + doc = document_new_file(name, ft, output); + document_set_encoding(doc, encodings_get_charset_from_index + (latex_encodings[local_enc].geany_enc)); + } +} + +void +glatex_wizard_activated(G_GNUC_UNUSED GtkMenuItem * menuitem, + G_GNUC_UNUSED gpointer gdata) +{ + gint i; + GString *code = NULL; + gchar *author = NULL; + gchar *date = NULL; + gchar *output = NULL; + gchar *classoptions = NULL; + gchar *title = NULL; + gchar *enc_latex_char = NULL; + gchar *documentclass_str = NULL; + gchar *papersize = NULL; + gchar *draft = NULL; + gchar *fontsize = NULL; + gint documentclass_int; + gint encoding_int; + gint papersize_int; + GtkWidget *dialog = NULL; + GtkWidget *vbox = NULL; + GtkWidget *label_documentclass = NULL; + GtkWidget *documentclass_combobox = NULL; + GtkWidget *label_encoding = NULL; + GtkWidget *encoding_combobox = NULL; + GtkWidget *fontsize_combobox = NULL; + GtkWidget *label_fontsize = NULL; + GtkWidget *table = NULL; + GtkWidget *checkbox_KOMA = NULL; + GtkWidget *author_textbox = NULL; + GtkWidget *label_author = NULL; + GtkWidget *date_textbox = NULL; + GtkWidget *label_date = NULL; + GtkWidget *title_textbox = NULL; + GtkWidget *label_title = NULL; + GtkWidget *papersize_combobox = NULL; + GtkWidget *label_papersize = NULL; + GtkWidget *checkbox_draft = NULL; + gboolean KOMA_active; + gboolean draft_active = FALSE; + + /* Creating and formatting table */ + table = gtk_table_new(2, 6, FALSE); + gtk_table_set_col_spacings(GTK_TABLE(table), 6); + gtk_table_set_row_spacings(GTK_TABLE(table), 6); + + /* Documentclass */ + label_documentclass = gtk_label_new(_("Documentclass:")); + documentclass_combobox = gtk_combo_box_new_text(); + ui_widget_set_tooltip_text(documentclass_combobox, + _("Choose the kind of document you want to write")); + gtk_combo_box_insert_text(GTK_COMBO_BOX(documentclass_combobox), 0, + _("Book")); + gtk_combo_box_insert_text(GTK_COMBO_BOX(documentclass_combobox), 1, + _("Article")); + gtk_combo_box_insert_text(GTK_COMBO_BOX(documentclass_combobox), 2, + _("Report")); + gtk_combo_box_insert_text(GTK_COMBO_BOX(documentclass_combobox), 3, + _("Letter")); + gtk_combo_box_insert_text(GTK_COMBO_BOX(documentclass_combobox), 4, + _("Presentation")); + + gtk_combo_box_set_active(GTK_COMBO_BOX(documentclass_combobox), 0); + + gtk_misc_set_alignment(GTK_MISC(label_documentclass), 0, 0.5); + + gtk_table_attach_defaults(GTK_TABLE(table), label_documentclass, 0, 1, 0, 1); + gtk_table_attach_defaults(GTK_TABLE(table), documentclass_combobox, 1, 2, 0, 1); + + /* Encoding */ + label_encoding = gtk_label_new(_("Encoding:")); + + encoding_combobox = gtk_combo_box_new_text(); + ui_widget_set_tooltip_text(encoding_combobox, + _("Set the encoding for your new document")); + for (i = 0; i < LATEX_ENCODINGS_MAX; i++) + { + gtk_combo_box_insert_text(GTK_COMBO_BOX(encoding_combobox), i, + latex_encodings[i].name); + } + + gtk_combo_box_set_active(GTK_COMBO_BOX(encoding_combobox), find_latex_enc(geany_data->file_prefs->default_new_encoding)); + + gtk_misc_set_alignment(GTK_MISC(label_encoding), 0, 0.5); + + gtk_table_attach_defaults(GTK_TABLE(table), label_encoding, 0, 1, 1, 2); + gtk_table_attach_defaults(GTK_TABLE(table), encoding_combobox, 1, 2, 1, 2); + + /* fontsize */ + + label_fontsize = gtk_label_new(_("Font size:")); + fontsize_combobox = gtk_combo_box_entry_new_text(); + gtk_combo_box_append_text(GTK_COMBO_BOX(fontsize_combobox),"10pt"); + gtk_combo_box_append_text(GTK_COMBO_BOX(fontsize_combobox),"11pt"); + gtk_combo_box_append_text(GTK_COMBO_BOX(fontsize_combobox),"12pt"); + ui_widget_set_tooltip_text(fontsize_combobox, + _("Set the default font size of your new document")); + + gtk_misc_set_alignment(GTK_MISC(label_fontsize), 0, 0.5); + + gtk_table_attach_defaults(GTK_TABLE(table), label_fontsize, 0, 1, 2, 3); + gtk_table_attach_defaults(GTK_TABLE(table), fontsize_combobox, 1, 2, 2, 3); + + /* Author */ + label_author = gtk_label_new(_("Author:")); + author_textbox = gtk_entry_new(); + ui_widget_set_tooltip_text(author_textbox, + _("Sets the value of the \author command. In most cases this should be your name")); + if (geany_data->template_prefs->developer != NULL) + { + author = geany_data->template_prefs->developer; + gtk_entry_set_text(GTK_ENTRY(author_textbox), author); + } + gtk_misc_set_alignment(GTK_MISC(label_author), 0, 0.5); + gtk_table_attach_defaults(GTK_TABLE(table), label_author, 0, 1, 3, 4); + gtk_table_attach_defaults(GTK_TABLE(table), author_textbox, 1, 2, 3, 4); + + /* Date */ + label_date = gtk_label_new(_("Date:")); + date_textbox = gtk_entry_new(); + ui_widget_set_tooltip_text(date_textbox, + _("Sets the value of the \date command inside header of your\ + newly created LaTeX-document. Keeping it at \today is a good \ + decision if you don't need any fixed date.")); + gtk_entry_set_text(GTK_ENTRY(date_textbox), "\today"); + gtk_misc_set_alignment(GTK_MISC(label_date), 0, 0.5); + gtk_table_attach_defaults(GTK_TABLE(table), label_date, 0, 1, 4, 5); + gtk_table_attach_defaults(GTK_TABLE(table), date_textbox, 1, 2, 4, 5); + + /* Title of the new document */ + label_title = gtk_label_new(_("Title:")); + title_textbox = gtk_entry_new(); + ui_widget_set_tooltip_text(title_textbox, + _("Sets the title of your new document.")); + gtk_misc_set_alignment(GTK_MISC(label_title), 0, 0.5); + gtk_table_attach_defaults(GTK_TABLE(table), label_title, 0, 1, 5, 6); + gtk_table_attach_defaults(GTK_TABLE(table), title_textbox, 1, 2, 5, 6); + + /* Papersize */ + label_papersize = gtk_label_new(_("Paper size:")); + papersize_combobox = gtk_combo_box_new_text(); + ui_widget_set_tooltip_text(papersize_combobox, + _("Choose the paper format for the newly created document")); + gtk_combo_box_insert_text(GTK_COMBO_BOX(papersize_combobox), 0, "A4"); + gtk_combo_box_insert_text(GTK_COMBO_BOX(papersize_combobox), 1, "A5"); + gtk_combo_box_insert_text(GTK_COMBO_BOX(papersize_combobox), 2, "A6"); + + gtk_combo_box_set_active(GTK_COMBO_BOX(papersize_combobox), 0); + + gtk_misc_set_alignment(GTK_MISC(label_papersize), 0, 0.5); + + gtk_table_attach_defaults(GTK_TABLE(table), label_papersize, 0, 1, 6, 7); + gtk_table_attach_defaults(GTK_TABLE(table), papersize_combobox, 1, 2, 6, 7); + + gtk_widget_show_all(table); + + /* Building the wizard-dialog and showing it */ + dialog = gtk_dialog_new_with_buttons(_("LaTeX-Wizard"), + GTK_WINDOW(geany->main_widgets->window), + GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, + GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, + NULL); + vbox = ui_dialog_vbox_new(GTK_DIALOG(dialog)); + gtk_widget_set_name(dialog, "GeanyDialog"); + gtk_box_set_spacing(GTK_BOX(vbox), 10); + gtk_container_add(GTK_CONTAINER(vbox), table); + + checkbox_KOMA = gtk_check_button_new_with_label( + _("Use KOMA-script classes if possible")); + ui_widget_set_tooltip_text(checkbox_KOMA, + _("Uses the KOMA-script classes by Markus Kohm.\n" + "Keep in mind: To compile your document these classes" + "have to be installed before.")); + gtk_button_set_focus_on_click(GTK_BUTTON(checkbox_KOMA), FALSE); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox_KOMA), glatex_set_koma_active); + gtk_box_pack_start(GTK_BOX(vbox), checkbox_KOMA, FALSE, FALSE, 5); + + checkbox_draft = gtk_check_button_new_with_label(_("Use draft mode")); + ui_widget_set_tooltip_text(checkbox_draft, + _("Set the draft flag inside new created documents to get " + "documents with a number of debugging helpers")); + gtk_button_set_focus_on_click(GTK_BUTTON(checkbox_draft), FALSE); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox_draft), draft_active); + gtk_box_pack_start(GTK_BOX(vbox), checkbox_draft, FALSE, FALSE, 5); + + gtk_widget_show_all(vbox); + + if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) + { + KOMA_active = gtk_toggle_button_get_active( + GTK_TOGGLE_BUTTON(checkbox_KOMA)); + draft_active = gtk_toggle_button_get_active( + GTK_TOGGLE_BUTTON(checkbox_draft)); + documentclass_int = gtk_combo_box_get_active( + GTK_COMBO_BOX(documentclass_combobox)); + encoding_int = gtk_combo_box_get_active( + GTK_COMBO_BOX(encoding_combobox)); + enc_latex_char = g_strconcat("\usepackage[", + latex_encodings[encoding_int].latex,"]{inputenc}\n", NULL); + author = g_strdup(gtk_entry_get_text(GTK_ENTRY(author_textbox))); + date = g_strdup(gtk_entry_get_text(GTK_ENTRY(date_textbox))); + title = g_strdup(gtk_entry_get_text(GTK_ENTRY(title_textbox))); + papersize_int = gtk_combo_box_get_active( + GTK_COMBO_BOX(papersize_combobox)); + switch (papersize_int) + { + case 0: + { + papersize = g_utf8_casefold("a4paper", -1); + break; + } + case 1: + { + papersize = g_utf8_casefold("a5paper", -1); + break; + } + case 2: + { + papersize = g_utf8_casefold("a6paper", -1); + break; + } + } + + fontsize = gtk_combo_box_get_active_text( + GTK_COMBO_BOX(fontsize_combobox)); + + if (papersize != NULL) + { + classoptions = g_strdup(papersize); + g_free(papersize); + } + if (classoptions != NULL && draft_active == TRUE) + { + draft = g_utf8_casefold("draft", -1); + classoptions = g_strconcat(classoptions,",", draft, NULL); + g_free(draft); + } + else if (classoptions == NULL && draft_active == TRUE) + { + draft = g_utf8_casefold("draft", -1); + classoptions = g_strconcat(draft, NULL); + g_free(draft); + } + if (classoptions != NULL && NZV(fontsize)) + { + classoptions = g_strconcat(classoptions, ",", fontsize, NULL); + } + else if (classoptions == NULL && NZV(fontsize)) + { + classoptions = g_strdup(fontsize); + } + g_free(fontsize); + + + switch (documentclass_int) + { + case 0: + { + documentclass_str = g_utf8_casefold("book", -1); + break; + } + case 1: + { + documentclass_str = g_utf8_casefold("article", -1); + break; + } + case 2: + { + documentclass_str = g_utf8_casefold("report", -1); + break; + } + case 3: + { + documentclass_str = g_utf8_casefold("letter", -1); + break; + } + case 4: + { + documentclass_str = g_utf8_casefold("beamer", -1); + } + } + + if (KOMA_active) + { + switch (documentclass_int) + { + case 0: + { + documentclass_str = g_utf8_casefold("scrbook", -1); + break; + } + case 1: + { + documentclass_str = g_utf8_casefold("scrartcl", -1); + break; + } + case 2: + { + documentclass_str = g_utf8_casefold("scrreprt", -1); + break; + } + } + + } + + if (documentclass_int == 3) + code = g_string_new(TEMPLATE_LATEX_LETTER); + else if (documentclass_int == 4) + code = g_string_new(TEMPLATE_LATEX_BEAMER); + else + code = g_string_new(TEMPLATE_LATEX); + + if (classoptions != NULL) + { + utils_string_replace_all(code, "{CLASSOPTION}", classoptions); + g_free(classoptions); + } + if (documentclass_str != NULL) + { + utils_string_replace_all(code, "{DOCUMENTCLASS}", documentclass_str); + g_free(documentclass_str); + } + if (enc_latex_char != NULL) + { + utils_string_replace_all(code, "{ENCODING}", enc_latex_char); + g_free(enc_latex_char); + } + if (author != NULL) + { + if (author[0] != '\0') + { + if (documentclass_int == 3) + { + author = g_strconcat("\signature{", author, "}\n", NULL); + } + else + { + author = g_strconcat("\author{", author, "}\n", NULL); + } + + utils_string_replace_all(code, "{AUTHOR}", author); + } + else + if (documentclass_int == 3) + { + utils_string_replace_all(code, "{AUTHOR}", "% \signature{}\n"); + } + else + { + utils_string_replace_all(code, "{AUTHOR}", "% \author{}\n"); + } + + g_free(author); + } + if (date != NULL) + { + if (date[0] != '\0') + { + date = g_strconcat("\date{", date, "}\n", NULL); + utils_string_replace_all(code, "{DATE}", date); + } + else + utils_string_replace_all(code, "{DATE}", "% \date{}\n"); + g_free(date); + } + if (title != NULL) + { + if (title[0] != '\0') + { + if (documentclass_int == 3) + { + title = g_strconcat("\subject{", title, "}\n", NULL); + } + else + { + title = g_strconcat("\title{", title, "}\n", NULL); + } + + utils_string_replace_all(code, "{TITLE}", title); + } + else + if (documentclass_int == 3) + { + utils_string_replace_all(code, "{TITLE}", "% \subject{} \n"); + } + else + { + utils_string_replace_all(code, "{TITLE}", "% \title{} \n"); + } + + g_free(title); + } + + utils_string_replace_all(code, "{OPENING}", _("Dear Sir or Madame")); + utils_string_replace_all(code, "{CLOSING}", _("With kind regards")); + + output = g_string_free(code, FALSE); + show_output(output, NULL, encoding_int); + g_free(output); + } + gtk_widget_destroy(dialog); +} + + +void init_keybindings() +{ + /* init keybindins */ + keybindings_set_item(plugin_key_group, KB_LATEX_WIZZARD, glatex_kbwizard, + 0, 0, "run_latex_wizard", _("Run LaTeX-Wizard"), menu_latex_wizzard); + keybindings_set_item(plugin_key_group, KB_LATEX_INSERT_LABEL, glatex_kblabel_insert, + 0, 0, "insert_latex_label", _("Insert \label"), menu_latex_label); + keybindings_set_item(plugin_key_group, KB_LATEX_INSERT_REF, glatex_kbref_insert, + 0, 0, "insert_latex_ref", _("Insert \ref"), menu_latex_ref); + keybindings_set_item(plugin_key_group, KB_LATEX_INSERT_NEWLINE, glatex_kb_insert_newline, + 0, 0, "insert_new_line", _("Insert linebreak \\ "), NULL); + keybindings_set_item(plugin_key_group, KB_LATEX_TOGGLE_ACTIVE, glatex_kblatex_toggle, + 0, 0, "latex_toggle_status", _("Turn input replacement on/off"), + menu_latex_replace_toggle); + keybindings_set_item(plugin_key_group, KB_LATEX_REPLACE_SPECIAL_CHARS, + glatex_kb_replace_special_chars, 0, 0, "latex_replace_chars", + _("Replace special characters"), NULL); + keybindings_set_item(plugin_key_group, KB_LATEX_ENVIRONMENT_INSERT, + glatex_kbref_insert_environment, 0, 0, "latex_insert_environment", + _("Run insert environment dialog"), menu_latex_insert_environment); + keybindings_set_item(plugin_key_group, KB_LATEX_INSERT_NEWITEM, + glatex_kb_insert_newitem, 0, 0, "latex_insert_item", _("Insert \item"), NULL); + keybindings_set_item(plugin_key_group, KB_LATEX_FORMAT_BOLD, glatex_kb_format_bold, + 0, 0, "format_bold", _("Format selection in bold font face"), NULL); + keybindings_set_item(plugin_key_group, KB_LATEX_FORMAT_ITALIC, glatex_kb_format_italic, + 0, 0, "format_italic", _("Format selection in italic font face"), NULL); + keybindings_set_item(plugin_key_group, KB_LATEX_FORMAT_TYPEWRITER, glatex_kb_format_typewriter, + 0, 0, "format_typewriter", _("Format selection in typewriter font face"), NULL); + keybindings_set_item(plugin_key_group, KB_LATEX_FORMAT_CENTER, glatex_kb_format_centering, + 0, 0, "format_center", _("Format selection centered"), NULL); + keybindings_set_item(plugin_key_group, KB_LATEX_FORMAT_LEFT, glatex_kb_format_left, + 0, 0, "format_left", _("Format selection left-aligned"), NULL); + keybindings_set_item(plugin_key_group, KB_LATEX_FORMAT_RIGHT, glatex_kb_format_right, + 0, 0, "format_right", _("Format selection right-aligned "), NULL); +} + +void plugin_help() +{ + dialogs_show_msgbox(GTK_MESSAGE_INFO, + _("GeanyLaTeX is a plugin to improve support for LaTeX in Geany." + "\n\nPlease report all bugs or feature requests to one of the " + "authors.")); +} + +void +plugin_init(G_GNUC_UNUSED GeanyData * data) +{ + GtkWidget *tmp = NULL; + GKeyFile *config = g_key_file_new(); + gint i; + + /* loading configurations from file ...*/ + config_file = g_strconcat(geany->app->configdir, G_DIR_SEPARATOR_S, + "plugins", G_DIR_SEPARATOR_S, + "geanyLaTeX", G_DIR_SEPARATOR_S, "general.conf", NULL); + + /* ... and Initialising options from config file */ + g_key_file_load_from_file(config, config_file, G_KEY_FILE_NONE, NULL); + + glatex_set_koma_active = utils_get_setting_boolean(config, "general", + "glatex_set_koma_active", FALSE); + + glatex_set_toolbar_active = utils_get_setting_boolean(config, "general", + "glatex_set_toolbar_active", FALSE); + + main_locale_init(LOCALEDIR, GETTEXT_PACKAGE); + + g_key_file_free(config); + + + glatex_init_encodings_latex(); + + menu_latex = gtk_menu_item_new_with_mnemonic(_("_LaTeX")); + gtk_container_add(GTK_CONTAINER(geany->main_widgets->tools_menu), menu_latex); + + menu_latex_menu = gtk_menu_new(); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_latex), menu_latex_menu); + + menu_latex_wizzard = ui_image_menu_item_new(GTK_STOCK_NEW, _("LaTeX-_Wizard")); + gtk_container_add(GTK_CONTAINER(menu_latex_menu), menu_latex_wizzard); + ui_widget_set_tooltip_text(menu_latex_wizzard, + _("Starts a Wizard to easily create LaTeX-documents")); + + g_signal_connect(menu_latex_wizzard, "activate", + G_CALLBACK(glatex_wizard_activated), NULL); + + menu_latex_menu_special_char = gtk_menu_item_new_with_mnemonic(_("Insert _Special Character")); + ui_widget_set_tooltip_text(menu_latex_menu_special_char, + _("Helps to use some not very common letters and signs")); + gtk_container_add(GTK_CONTAINER(menu_latex_menu), + menu_latex_menu_special_char); + + menu_latex_menu_special_char_submenu = gtk_menu_new(); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_latex_menu_special_char), + menu_latex_menu_special_char_submenu); + glatex_sub_menu_init(menu_latex_menu_special_char_submenu, glatex_char_array, glatex_cat_names, + char_insert_activated); + + menu_latex_ref = gtk_menu_item_new_with_mnemonic(_("Insert _Reference")); + ui_widget_set_tooltip_text(menu_latex_ref, + _("Inserting references to the document")); + gtk_container_add(GTK_CONTAINER(menu_latex_menu), menu_latex_ref); + g_signal_connect(menu_latex_ref, "activate", + G_CALLBACK(glatex_insert_ref_activated), NULL); + + menu_latex_label = gtk_menu_item_new_with_mnemonic(_("Insert _Label")); + ui_widget_set_tooltip_text(menu_latex_label, + _("Helps at inserting labels to a document")); + gtk_container_add(GTK_CONTAINER(menu_latex_menu), menu_latex_label); + g_signal_connect(menu_latex_label, "activate", + G_CALLBACK(glatex_insert_label_activated), NULL); + + menu_latex_insert_environment = gtk_menu_item_new_with_mnemonic( + _("Insert _Environment")); + ui_widget_set_tooltip_text(menu_latex_insert_environment, + _("Helps at inserting an environment a document")); + gtk_container_add(GTK_CONTAINER(menu_latex_menu), menu_latex_insert_environment); + g_signal_connect(menu_latex_insert_environment, "activate", + G_CALLBACK(glatex_insert_environment_dialog), NULL); + + menu_latex_bibtex = gtk_menu_item_new_with_mnemonic(_("_BibTeX")); + gtk_container_add(GTK_CONTAINER(menu_latex_menu), menu_latex_bibtex); + + menu_latex_bibtex_submenu = gtk_menu_new(); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_latex_bibtex), + menu_latex_bibtex_submenu); + + for (i = 0; i < N_TYPES; i++) + { + tmp = NULL; + tmp = gtk_menu_item_new_with_mnemonic(_(glatex_label_types[i])); + gtk_container_add(GTK_CONTAINER(menu_latex_bibtex_submenu), tmp); + g_signal_connect(tmp, "activate", + G_CALLBACK(glatex_insert_bibtex_entry), GINT_TO_POINTER(i)); + } + + menu_latex_format_insert = gtk_menu_item_new_with_mnemonic(_("_Format")); + gtk_container_add(GTK_CONTAINER(menu_latex_menu), menu_latex_format_insert); + + menu_latex_format_insert_submenu = gtk_menu_new(); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_latex_format_insert), + menu_latex_format_insert_submenu); + + for (i = 0; i < LATEX_STYLES_END; i++) + { + tmp = NULL; + tmp = gtk_menu_item_new_with_mnemonic(_(glatex_format_labels[i])); + gtk_container_add(GTK_CONTAINER(menu_latex_format_insert_submenu), tmp); + g_signal_connect(tmp, "activate", + G_CALLBACK(glatex_insert_latex_format), GINT_TO_POINTER(i)); + } + + /* Add menuitem for LaTeX replacement functions*/ + menu_latex_replacement = gtk_menu_item_new_with_mnemonic( + _("_Special Character Replacement")); + menu_latex_replacement_submenu = gtk_menu_new(); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_latex_replacement), + menu_latex_replacement_submenu); + gtk_container_add(GTK_CONTAINER(menu_latex_menu), menu_latex_replacement); + + /* Add menuitem for bulk replacment */ + menu_latex_replace_selection = gtk_menu_item_new_with_mnemonic( + _("Bulk _Replace Special Characters")); + ui_widget_set_tooltip_text(menu_latex_replace_selection, + _("_Replace selected special cahracters with TeX substitutes")); + gtk_container_add(GTK_CONTAINER(menu_latex_replacement_submenu), + menu_latex_replace_selection); + g_signal_connect(menu_latex_replace_selection, "activate", + G_CALLBACK(glatex_replace_special_character), NULL); + + /* Add menu entry for toggling input replacment */ + menu_latex_replace_toggle = gtk_check_menu_item_new_with_mnemonic( + _("Toggle _Special Character Replacement")); + gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(menu_latex_replace_toggle), + toggle_active); + gtk_container_add(GTK_CONTAINER(menu_latex_replacement_submenu), + menu_latex_replace_toggle); + + g_signal_connect(menu_latex_replace_toggle, "activate", + G_CALLBACK(glatex_toggle_status), NULL); + + init_keybindings(); + if (glatex_set_toolbar_active == TRUE) + glatex_toolbar = init_toolbar(); + else + glatex_toolbar = NULL; + + ui_add_document_sensitive(menu_latex_menu_special_char); + ui_add_document_sensitive(menu_latex_ref); + ui_add_document_sensitive(menu_latex_label); + ui_add_document_sensitive(menu_latex_bibtex); + ui_add_document_sensitive(menu_latex_format_insert); + ui_add_document_sensitive(menu_latex_insert_environment); + ui_add_document_sensitive(menu_latex_replacement); + + gtk_widget_show_all(menu_latex); + main_menu_item = menu_latex; +} + +void +plugin_cleanup() +{ + gtk_widget_destroy(main_menu_item); + if (glatex_toolbar != NULL) + gtk_widget_destroy(glatex_toolbar); + + g_free(config_file); +}
Copied: trunk/geany-plugins/geanylatex/src/geanylatex.h (from rev 705, trunk/geanylatex/src/geanylatex.h) =================================================================== --- trunk/geany-plugins/geanylatex/src/geanylatex.h (rev 0) +++ trunk/geany-plugins/geanylatex/src/geanylatex.h 2009-06-11 21:30:17 UTC (rev 706) @@ -0,0 +1,124 @@ + /* + * geanylatex.h + * + * Copyright 2008-2009 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +/* LaTeX plugin */ +/* This plugin improves the work with LaTeX and Geany.*/ + +#ifndef GEANYLATEX_H +#define GEANYLATEX_H + + +#include "geany.h" +#include "support.h" +#include "document.h" +#include "editor.h" +#include "filetypes.h" +#include "templates.h" +#include "dialogs.h" +#include "utils.h" +#include "ui_utils.h" +#include "keybindings.h" +#include "prefs.h" +#include "datatypes.h" +#include "letters.h" +#include "latexencodings.h" +#include "bibtex.h" +#include "latexutils.h" +#include "reftex.h" +#include "latexenvironments.h" +#include "formatutils.h" +#include "latexkeybindings.h" +#include "Scintilla.h" +#include "plugindata.h" +#include "geanyfunctions.h" + + +#include <gtk/gtk.h> + +#ifdef HAVE_LOCALE_H +# include <locale.h> +#endif + +#include <string.h> +typedef void (*MenuCallback) (G_GNUC_UNUSED GtkMenuItem * menuitem, G_GNUC_UNUSED gpointer gdata); + + +extern GeanyPlugin *geany_plugin; +extern GeanyData *geany_data; +extern GeanyFunctions *geany_functions; + + +#define TEMPLATE_LATEX "\ +\documentclass[{CLASSOPTION}]{{DOCUMENTCLASS}}\n\ +{ENCODING}\ +{TITLE}\ +{AUTHOR}\ +{DATE}\ +\begin{document}\n\ +\n\ +\end{document}\n" + +#define TEMPLATE_LATEX_LETTER "\ +\documentclass[{CLASSOPTION}]{{DOCUMENTCLASS}}\n\ +{ENCODING}\ +\address{}\n\ +{DATE}\ +{TITLE}\ +{AUTHOR}\ +\begin{document}\n\ +\begin{letter}{}\n\ +\opening{{OPENING}}\n\n\ +\closing{{CLOSING}}\n\ +\end{letter}\n\ +\end{document}\n" + +#define TEMPLATE_LATEX_BEAMER "\ +\documentclass[]{{DOCUMENTCLASS}}\n\ +\usetheme{default}\n\ +{ENCODING}\ +{TITLE}\ +{AUTHOR}\ +{DATE}\ +\begin{document}\n\ +\frame{\titlepage}\n\ +\begin{frame}\n\ +\end{frame}\n\ +\end{document}\n" + +#define create_sub_menu(base_menu, menu, item, title) \ + (menu) = gtk_menu_new(); \ + (item) = gtk_menu_item_new_with_mnemonic(_(title)); \ + gtk_menu_item_set_submenu(GTK_MENU_ITEM((item)), (menu)); \ + gtk_container_add(GTK_CONTAINER(base_menu), (item)); \ + gtk_widget_show((item)); + +#define MAX_MENU_ENTRIES 20 + +extern void glatex_insert_string(gchar *string, gboolean reset_position); +gint glatex_count_menu_entries(SubMenuTemplate *tmp, gint categorie); +void glatex_wizard_activated(G_GNUC_UNUSED GtkMenuItem * menuitem, + G_GNUC_UNUSED gpointer gdata); +void glatex_insert_label_activated(G_GNUC_UNUSED GtkMenuItem * menuitem, + G_GNUC_UNUSED gpointer gdata); +void glatex_insert_ref_activated(G_GNUC_UNUSED GtkMenuItem * menuitem, + G_GNUC_UNUSED gpointer gdata); +void glatex_replace_special_character(); +#endif
Copied: trunk/geany-plugins/geanylatex/src/latexencodings.c (from rev 705, trunk/geanylatex/src/latexencodings.c) =================================================================== --- trunk/geany-plugins/geanylatex/src/latexencodings.c (rev 0) +++ trunk/geany-plugins/geanylatex/src/latexencodings.c 2009-06-11 21:30:17 UTC (rev 706) @@ -0,0 +1,59 @@ +/* + * latexencodings.h + * + * Copyright 2008 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#include <gtk/gtk.h> +#include "support.h" +#include "encodings.h" +#include "latexencodings.h" + +LaTeXEncodings latex_encodings[LATEX_ENCODINGS_MAX]; + +#define fill(Charset, Name, LaTeX, GeanyEnc) \ + latex_encodings[Charset].charset = Charset; \ + latex_encodings[Charset].name = Name; \ + latex_encodings[Charset].latex = LaTeX; \ + latex_encodings[Charset].geany_enc = GeanyEnc; + +void glatex_init_encodings_latex(void) +{ + fill(LATEX_ENCODING_UTF_8, _("UTF-8"), "utf8", GEANY_ENCODING_UTF_8); + fill(LATEX_ENCODING_ASCII, _("US-ASCII"), "ascii", GEANY_ENCODING_ISO_8859_1); + fill(LATEX_ENCODING_ISO_8859_1, _("ISO-8859-1 (Latin-1)"), "latin1", + GEANY_ENCODING_ISO_8859_1); + fill(LATEX_ENCODING_ISO_8859_2, _("ISO-8859-2 (Latin-2)"), "latin2", + GEANY_ENCODING_ISO_8859_2); + fill(LATEX_ENCODING_ISO_8859_3, _("ISO-8859-3 (Latin-3)"), "latin3", + GEANY_ENCODING_ISO_8859_3); + fill(LATEX_ENCODING_ISO_8859_4, _("ISO-8859-4 (Latin-4)"), "latin4", + GEANY_ENCODING_ISO_8859_4); + fill(LATEX_ENCODING_ISO_8859_5, _("ISO-8859-5 (Latin-5)"), "latin5", + GEANY_ENCODING_ISO_8859_5); + fill(LATEX_ENCODING_ISO_8859_9, _("ISO-8859-9 (Latin-9)"), "latin9", + GEANY_ENCODING_ISO_8859_9); + fill(LATEX_ENCODING_ISO_8859_10, _("ISO-8859-10 (Latin-10)"), "latin10", + GEANY_ENCODING_ISO_8859_10); + fill(LATEX_ENCODING_IBM_850, _("IBM 850 code page"), "cp850", + GEANY_ENCODING_IBM_850); + fill(LATEX_ENCODING_IBM_852, _("IBM 852 code page"), "cp852", + GEANY_ENCODING_IBM_852); + fill(LATEX_ENCODING_NONE, _("Misc"), NULL, + GEANY_ENCODING_NONE); +}
Copied: trunk/geany-plugins/geanylatex/src/latexencodings.h (from rev 705, trunk/geanylatex/src/latexencodings.h) =================================================================== --- trunk/geany-plugins/geanylatex/src/latexencodings.h (rev 0) +++ trunk/geany-plugins/geanylatex/src/latexencodings.h 2009-06-11 21:30:17 UTC (rev 706) @@ -0,0 +1,56 @@ +/* + * latexencodings.h + * + * Copyright 2008 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#ifndef LATEXEXCODINGS_H +#define LATEXEXCODINGS_H + + +typedef enum +{ + LATEX_ENCODING_UTF_8 = 0, + LATEX_ENCODING_ASCII, + LATEX_ENCODING_ISO_8859_1, + LATEX_ENCODING_ISO_8859_2, + LATEX_ENCODING_ISO_8859_3, + LATEX_ENCODING_ISO_8859_4, + LATEX_ENCODING_ISO_8859_5, + LATEX_ENCODING_ISO_8859_9, + LATEX_ENCODING_ISO_8859_10, + LATEX_ENCODING_IBM_850, + LATEX_ENCODING_IBM_852, + LATEX_ENCODING_NONE, + LATEX_ENCODINGS_MAX +} LaTeXEncodingIndex; + + +typedef struct +{ + LaTeXEncodingIndex charset; + gchar *name; + gchar *latex; + gint geany_enc; +} LaTeXEncodings; + +extern LaTeXEncodings latex_encodings[LATEX_ENCODINGS_MAX]; + +void glatex_init_encodings_latex(void); + +#endif
Copied: trunk/geany-plugins/geanylatex/src/latexenvironments.c (from rev 705, trunk/geanylatex/src/latexenvironments.c) =================================================================== --- trunk/geany-plugins/geanylatex/src/latexenvironments.c (rev 0) +++ trunk/geany-plugins/geanylatex/src/latexenvironments.c 2009-06-11 21:30:17 UTC (rev 706) @@ -0,0 +1,168 @@ +/* + * latexenvironments.c + * + * Copyright 2009 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#include "latexenvironments.h" + +CategoryName glatex_environment_cat_names[] = { + { ENVIRONMENT_CAT_DUMMY, N_("Environments"), TRUE}, + { ENVIRONMENT_CAT_FORMAT, N_("Formating"), TRUE}, + { ENVIRONMENT_CAT_STRUCTURE, N_("Document Structure"), TRUE}, + { ENVIRONMENT_CAT_LISTS, N_("Lists"), TRUE}, + { ENVIRONMENT_CAT_MATH, N_("Math"), TRUE}, + { 0, NULL, FALSE} +}; + + +SubMenuTemplate glatex_environment_array[] = { + /* General document structure environments */ + {ENVIRONMENT_CAT_STRUCTURE, "block", "block"}, + {ENVIRONMENT_CAT_STRUCTURE, "document", "document"}, + {ENVIRONMENT_CAT_STRUCTURE, "frame", "frame"}, + {ENVIRONMENT_CAT_STRUCTURE, "table", "table"}, + {ENVIRONMENT_CAT_STRUCTURE, "tabular", "tabular"}, + {ENVIRONMENT_CAT_STRUCTURE, "figure", "figure"}, + /* Lists */ + {ENVIRONMENT_CAT_LISTS, "itemize", "itemize"}, + {ENVIRONMENT_CAT_LISTS, "enumerate", "enumerate"}, + {ENVIRONMENT_CAT_LISTS, "description", "description"}, + /* Math stuff */ + {ENVIRONMENT_CAT_MATH, "displaymath", "displaymath"}, + {ENVIRONMENT_CAT_MATH, "equation", "equation"}, + {ENVIRONMENT_CAT_MATH, "eqnarray", "eqnarray"}, + + {0, NULL, NULL}, +}; + + +void glatex_insert_environment(gchar *environment) +{ + GeanyDocument *doc = NULL; + + doc = document_get_current(); + + /* Only do anything if it is realy needed to */ + if (doc != NULL && environment != NULL) + { + if (sci_has_selection(doc->editor->sci)) + { + gchar *selection = NULL; + const gchar *replacement = NULL; + + selection = sci_get_selection_contents(doc->editor->sci); + + replacement = g_strconcat("\begin{", environment, "}\n", + selection,"\n\end{", environment, "}\n", NULL); + + sci_replace_sel(doc->editor->sci, replacement); + g_free(selection); + } + else + { + gint pos = sci_get_current_position(doc->editor->sci); + gint len = strlen(environment); + gchar *tmp = NULL; + + tmp = g_strconcat("\begin{", environment, "}\n\n\end{", + environment, "}\n", NULL); + + sci_insert_text(doc->editor->sci, pos, tmp); + sci_set_current_position(doc->editor->sci, pos + len + 9, TRUE); + g_free(tmp); + } + } +} + + +void +glatex_environment_insert_activated (G_GNUC_UNUSED GtkMenuItem *menuitem, + G_GNUC_UNUSED gpointer gdata) +{ + gint env = GPOINTER_TO_INT(gdata); + + glatex_insert_environment(glatex_environment_array[env].latex); +} + + +void +glatex_insert_environment_dialog(G_GNUC_UNUSED GtkMenuItem *menuitem, + G_GNUC_UNUSED gpointer gdata) +{ + GtkWidget *dialog = NULL; + GtkWidget *vbox = NULL; + GtkWidget *label_env = NULL; + GtkWidget *textbox_env = NULL; + GtkWidget *table = NULL; + GtkTreeModel *model = NULL; + gint i, max; + + dialog = gtk_dialog_new_with_buttons(_("Insert Environment"), + GTK_WINDOW(geany->main_widgets->window), + GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, + GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, + NULL); + + vbox = ui_dialog_vbox_new(GTK_DIALOG(dialog)); + gtk_widget_set_name(dialog, "GeanyDialog"); + gtk_box_set_spacing(GTK_BOX(vbox), 10); + + table = gtk_table_new(1, 2, FALSE); + gtk_table_set_col_spacings(GTK_TABLE(table), 6); + gtk_table_set_row_spacings(GTK_TABLE(table), 6); + + label_env = gtk_label_new(_("Environment:")); + textbox_env = gtk_combo_box_entry_new_text(); + + max = glatex_count_menu_entries(glatex_environment_array, -1); + for (i = 0; i < max; i++) + { + gtk_combo_box_append_text(GTK_COMBO_BOX(textbox_env), + glatex_environment_array[i].label); + } + + model = gtk_combo_box_get_model(GTK_COMBO_BOX(textbox_env)); + gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(model), + 0, GTK_SORT_ASCENDING); + + gtk_misc_set_alignment(GTK_MISC(label_env), 0, 0.5); + + gtk_table_attach_defaults(GTK_TABLE(table), label_env, 0, 1, 0, 1); + gtk_table_attach_defaults(GTK_TABLE(table), textbox_env, 1, 2, 0, 1); + gtk_container_add(GTK_CONTAINER(vbox), table); + + gtk_widget_show_all(vbox); + + if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) + { + gchar *env_string = NULL; + + env_string = g_strdup(gtk_combo_box_get_active_text( + GTK_COMBO_BOX(textbox_env))); + + if (env_string != NULL) + { + glatex_insert_environment(env_string); + g_free(env_string); + } + } + + gtk_widget_destroy(dialog); +} +
Copied: trunk/geany-plugins/geanylatex/src/latexenvironments.h (from rev 705, trunk/geanylatex/src/latexenvironments.h) =================================================================== --- trunk/geany-plugins/geanylatex/src/latexenvironments.h (rev 0) +++ trunk/geany-plugins/geanylatex/src/latexenvironments.h 2009-06-11 21:30:17 UTC (rev 706) @@ -0,0 +1,51 @@ +/* + * latexenvironments.h + * + * Copyright 2009 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#ifndef LATEXENVIRONMENTS_H +#define LATEXENVIRONMENTS_H + +#include "geanylatex.h" +#include <string.h> + +enum { + ENVIRONMENT_CAT_DUMMY = 0, + ENVIRONMENT_CAT_FORMAT, + ENVIRONMENT_CAT_STRUCTURE, + ENVIRONMENT_CAT_LISTS, + ENVIRONMENT_CAT_MATH, + ENVIRONMENT_CAT_MAX +}; + +extern SubMenuTemplate glatex_environment_array[]; + +extern CategoryName glatex_environment_cat_names[]; + +void glatex_insert_environment(gchar *environment); + +void +glatex_insert_environment_dialog(G_GNUC_UNUSED GtkMenuItem *menuitem, + G_GNUC_UNUSED gpointer gdata); + +void +glatex_environment_insert_activated (G_GNUC_UNUSED GtkMenuItem *menuitem, + G_GNUC_UNUSED gpointer gdata); + +#endif
Copied: trunk/geany-plugins/geanylatex/src/latexkeybindings.c (from rev 705, trunk/geanylatex/src/latexkeybindings.c) =================================================================== --- trunk/geany-plugins/geanylatex/src/latexkeybindings.c (rev 0) +++ trunk/geany-plugins/geanylatex/src/latexkeybindings.c 2009-06-11 21:30:17 UTC (rev 706) @@ -0,0 +1,112 @@ +/* + * latexkeybindings.c + * + * Copyright 2009 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#include "latexkeybindings.h" + +void glatex_kblabel_insert(G_GNUC_UNUSED guint key_id) +{ + if (NULL == document_get_current()) + return;
@@ Diff output truncated at 100000 characters. @@
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.