Eclipse

Eclipse IDE for C/C++ Developers

 * http://www.eclipse.org/downloads/
 * http://www.eclipse.org/downloads/index-developer.php
 * http://www.eclipse.org/cdt/
 * http://wiki.eclipse.org/CDT
 * http://download.eclipse.org/tools/cdt/builds/
 * http://eclipsesource.com/blogs/
 * http://eclipse.dzone.com/
 * http://mcuoneclipse.wordpress.com/category/eclipse-2/

The CDT is Eclipse's C/C++ Development Tooling project.

Simultaneous Release
 * Eclipse Helios (3.6) - previous (June 2010)
 * Eclipse CDT - C/C++ Development Tools (7.0)
 * Eclipse Indigo (3.7)  - current (June 2011)
 * Eclipse CDT - C/C++ Development Tools (8.0)
 * Eclipse Juno (4.2)  - planned (June 2012)
 * Eclipse CDT - C/C++ Development Tools (9.0)

Install
$ su - $ tar -xzf eclipse-cpp-indigo-*-linux-gtk-x86_64.tar.gz -C /opt/ $ chmod -R +r /opt/eclipse/ $ chown -R root:root /opt/eclipse/
 * Stiahnuty eclipse tarball subor extrahovat do potrebnej directory, bud do user home dir, alebo skor do dir nezavislej od user-a

[Desktop Entry] Type=Application Name=Eclipse Comment=Eclipse IDE Exec=/opt/eclipse/eclipse Icon=/opt/eclipse/icon.xpm Terminal=false Categories=Development;IDE; StartupNotify=true
 * Aplikaciu pridame do menu vytvorenim suboru
 * 1) Exec=env GTK_THEME=Adwaita:dark /opt/eclipse/eclipse


 * V pripade ak instalujem Eclipse do nie user home dir, tak bug-om - bug 249133 vsetky linky z Available Software Sites (odkial sa potom instaluju pluginy, updates) su nepristupne/neviditelne . V pripade ak je nainstalovany v user home dir tak linky su pristupne. Preto si docasne Eclipse nainstalujem (jednoducho rozpakujem tarball) do home dir. Spustim ho z home dir . Linky su teraz pristupne. Window -> Preferences => Install/Update -> Available Software Sites oznacim vsetky Location a exportujem do suboru . Mazem docasne nainstalovany Eclipse z home dir, a spustam ho z user-a nezavislej dir . Importujem nedavno vytvoreny subor . Update: po nainstalovani akehokolvek plugin-a (pomocou Eclipse mechanizmu Help -> Install New Software) sa linky, ktore boli pred tym nepristupne/neviditelne, automaticky spristupnia, t.j. nic z vyssie uvedeneho uz nie je potrebne robit.


 * Eclipse CDT je nainstalovany nezavisle od user-a (cista distribucia), vsetky potrebne subory (pluginy a pod.) sa budu ukladat v home dir

$ yum install eclipse-cdt
 * Stale je tu moznost instalacie priamo z Fedora repository


 * Pre spustenie Eclipse je potrebne Java runtime environment (JRE)
 * Oracle-Java JRE odporucana Eclipse Foundation, avsak s Fedorou problem Eclipse CDT indexer crashes in Fedora 14, preto je bolo potrebne v subore pridat tento riadok:
 * OpenJDK-Java podporovana, udajne sa vsak mozu vyskytnut problemy, na Fedore sa zda byt vsetko v poriadku
 * GCJ-Java neodporucana Eclipse Foundation

simple CERN ROOT project
g++ -I$ROOTSYS/include -L/cern/root/lib -lCore -lCint -lRIO -lHist -lGraf -lGpad -lMatrix -lMathCore -lThread -o hworld.exe $ROOTSYS/test/hworld.cxx
 * Jednoduchy priklad, ktory ukazuje ako v Eclipse pracovat (editacia, kompilacia, ...) napr. so suborom $ROOTSYS/test/hworld.cxx
 * Najprv musim vytvorit novy projekt File -> New -> C++ Project => Executable -> Empty Project (pripadne Hello World C++ Project). V polozke Project Name zadam meno, napr. test, nastavim Location, kde sa budu vsetky subory projektu ukladat. V polozke Select Configuration staci vybrat len Release
 * V existujucom projekte mozem bud vytvorit novy subor, alebo jednoducho importujem uz existujuci subor(y). File -> Import => General -> File System vyberiem dir, kde sa nachadza nas testovy subor a oznacim len tento jeden subor na importovanie
 * Subor/program sa kompiluje (a linkuje) nasledovne
 * alebo pomocou utility

g++ -c $ROOTSYS/test/hworld.cxx `root-config --cflags` g++ -o hworld.exe hworld.o `root-config --glibs`
 * V Eclipse je potrebne nastavit kompilator a linker pre spolupracu s ROOT framework-om. Project -> Properties, resp. vyberieme nas (test) projekt v okne Project Explorer a stlacime, dalej:
 * C/C++ Build -> Settings -> Tool Settings -> GCC C++ Compiler -> Miscellaneous | Other flags pridat  
 * C/C++ Build -> Settings -> Tool Settings -> GCC C++ Linker -> Miscellaneous | Linker flags pridat  
 * C/C++ Build -> Settings -> Tool Settings jednotlive premenne, napr. Inlcude paths (-I), Libraries (-l), Library path (-L), atd mozem nastavit aj manualne, t.j. kompilovat bez utility
 * Pre spravne fungovanie C/C++ Indexer (v Eclipse sa spusta Run C/C++ Code Analysis)
 * C/C++ General -> Path and Symbols -> Includes -> GNU C++ | Include directories pridat  
 * V pripade, ak nastavim napr. premennu Inlcude paths (-I) v C/C++ Build -> Settings -> Tool Settings -> GCC C++ Compiler manualne, tak Eclipse si ju automaticky dopise aj do C/C++ General -> Path and Symbols -> Includes -> GNU C++ a naopak, to iste plati aj aj pre ostatne premenne
 * Project -> Build All vytvorime projekt (Eclipse vytvori potrebny ), ktory sa nasledovne aj skompiluje, alebo projekt priamo spustime Run -> Run

project STRELA
File -> Import => C/C++ -> Existing Code as Makefile Project (alebo File -> New -> Makefile Project with Existing Code). V polozke Existing Code Location vyberiem directory, kde sa nachadzaju zdrojove subory (vratane ). Nastavim C++ ako Languages a Linux GCC ako Toolchain for Indexer Settings File -> Import => Git -> Projects from Git. Najprv si vytvorim Git Repository kliknutim na Clone, v polozke Location nastavim URI projektu. Vyberiem potrebny branch (master) a cestu, kde sa projekt naklonuje. Teraz si uz mozem vyberat prave naklonovany Git Repository. V Wizard for project import vyberam Use the New Projects Wizard a postupujem analogicky ako v pripade, ked su subory na lokalnom disku.
 * Priklad kedy uz kod existuje, zdrojove subory projektu STRELA sa nachadzaju v GitHub repository https://github.com/musinsky/strela
 * Vytvorenie projektu zo suborov, ktore su
 * na lokalnom disku.
 * v GitHub repository. Potrebne nainstalovat EGit plugin pre podporu Git (analogicky mozno pouzit aj SVN, resp. CVS)
 * Kedze uz pouzivam existujuci, tak v C/C++ Build -> Settings nie je potrebne (a ani nie je mozne) nic nastavovat, aj samotne polozky v menu su uz odlisne ako napr. v pripade simple ROOT project (Empty Project)
 * C/C++ General -> Path and Symbols -> Includes -> GNU C++ | Include directories pridat  
 * C/C++ Build -> Behaviour v polozke Clean nastavit distclean, resp. pozriet do projektu STRELA, mozno taktiez nastavit potrebnu hodnotu Use parallel jobs
 * C/C++ General -> Path and Symbols -> Source Location kliknutim na Edit Filter mozem priamo nastavit Source Folder Exclusion Patterns, pre STRELA projekt napr.:, , . Kedykolvek neskor mozem presne to iste urobit v okne Project Explorer, kliknutim myskou na potrebnu directory a nasledovne Resource Configurations -> Exclude From Build

GTK Theme

 * http://techtavern.wordpress.com/2008/09/24/smaller-font-sizes-for-eclipse-on-linux/
 * http://blog.sarathonline.com/2008/10/solved-eclipse-looks-good-in-ubuntu-now.html
 * http://stackoverflow.com/questions/8628864/how-to-modify-color-of-inactive-line-in-code-assist-in-eclipse
 * http://gnome-look.org/content/show.php?content=69357&forumpage=1
 * http://ironman.darthgibus.net/?p=148

spolocny pre vsetky progrmay, ktore vyuzivaju GTK2 theme (Firefox, Chrome, LibreOffice, Eclipse ...)
 * https://gist.github.com/1827468

style "eclipse-simple" { font_name = "Sans 9" } class "GtkWidget" style "eclipse-simple" $ GTK2_RC_FILES=/usr/share/themes/Adwaita/gtk-2.0/gtkrc:~/.gtkrc-eclipse-simple /opt/eclipse/eclipse $ GTK2_RC_FILES=~/.gtkrc-eclipse-simple /opt/eclipse/eclipse create launcher env GTK2_RC_FILES=/usr/share/themes/Adwaita/gtk-2.0/gtkrc:~/.gtkrc-eclipse-simple '/opt/eclipse/eclipse'

Eclipse CSS

 * https://github.com/jeeeyul/eclipse-themes
 * http://www.vogella.com/articles/Eclipse4CSS/article.html


 * http://eclipse.dzone.com/articles/editing-eclipse-4-workbench
 * http://habrahabr.ru/post/147417/

.MPartStack { font-size: 11; swt-simple: false; swt-mru-visible: false; }

Preferences

 * Preferences su workspace specificke, t.j. ak vytvorim iny workspace, tak nastavenia sa zmenia, moznost Import/Export vsetkych (vratane plugin-ovskych) nastaveni: File -> Import/Export => General -> Preferences
 * Restore Defaults v preferences okne sa vztahuje ku konkretnemu typu nastavenia (len pre konkretne okno) a nie pre vsetky nastavenia


 * General
 * Appearance -> Label Decorations
 * C/C++ Indexed Files - zapnut
 * Compare/Patch | Text Compare
 * Connect ranges with single line - lepsie asi vypnut
 * Editors -> Text Editors
 * Insert spaces for tabs - neskor aj tak bude prepisane nastaveniami profilu (Tab policy: Spaces only)
 * Show print margin - zapnut a nastavit Print margin column na 120
 * Show line numbers - lepsie asi zapnut
 * C/C++ Code style/format
 * Editors -> Text Editors -> Quick Diff
 * Show differences in overview ruler - zapnut
 * Use this reference source - podla potreby Version on Disk pripadne A Git Revision
 * Editors -> Text Editors -> Spelling
 * Enable spell checking - vypnut
 * Workspace
 * Build automatically - pri vacsich projektoch lepsie asi vypnut


 * C/C++
 * Code Style
 * C/C++ Code style/format
 * Code Style -> Code Templates
 * TODO
 * Editor -> Folding
 * Enable folding when opening a new editor - zlucovanie/zoskupovanie macros/functions a pod. v editore zdrojoveho kodu
 * Header Comments - vypnut
 * Editor -> Templates
 * TODO

wget https://raw.github.com/gist/1095765/eclipse_custom.ini wget https://raw.github.com/gist/1095765/profile_AliRoot.xml sed 's/=/\\=/g' profile_AliRoot.xml > profile_AliRoot.tmp sed -i ':a;N;$!ba;s/\n/\\n/g' profile_AliRoot.tmp echo "org.eclipse.cdt.ui/org.eclipse.cdt.ui.formatterprofiles="`cat profile_AliRoot.tmp` > profile_AliRoot.tmp sed -i '/formatter_profile/ r profile_AliRoot.tmp' eclipse_custom.ini
 * 1) replace all "=" by "\="
 * 1) replace all 'end of line' by "\n"
 * 1) append "...formatterprofiles"
 * 1) insert 'profile_AliRoot.tmp' file in 'eclipse_custom.ini' file (after "formatter_profile" word)

now start eclipse $ eclipse -plugincustomization /opt/eclipse/eclipse_custom.ini or add to file -Declipse.pluginCustomization=/opt/eclipse/eclipse_custom.ini -showlocation

C/C++ Code style/format
It is now possible to format source code without starting the Eclipse UI using the new headless formatter application. The command line formatter works as a standard Eclipse application. The following command will format the source files in the folder src with the options specified in the org.eclipse.cdt.core.prefs file: eclipse -nosplash -application org.eclipse.cdt.core.CodeFormatter -consoleLog \ -verbose -config .settings/org.eclipse.cdt.core.prefs src/ Format zdrojoveho kodu je podstatny zasah da struktury textu, hrubo povedane sa upravuje "slovo za slovom" podla prednastavenych pravidiel. Correct Indentation v podstate iba zarovnava/osadzuje kazdy riadok zdrojoveho kodu, takisto podla prednastavenych pravidiel, ale zmeny v kode uz nie su na tolko rozsiahle.
 * https://wiki.eclipse.org/CDT/User/NewIn94

Eclipse ma uz vstavany vlastny Code Style s roznymi profilmi (K&R, GNU, ...), avsak ten zasadne moze menit formu, strukturu zdrojoveho kodu. Aby sa priblizit k ROOT C++ Coding Conventions, resp. AliRoot Coding Conventions bolo by potrebne takyto profil zasadne zmenit, resp. ho vypnut, co vsak nie je (asi) mozne, preto potrebna zamena na Astyle Eclipse C/C++ formatter. Treba vsak priznat, ze ROOT C++ Coding Conventions pouziva znacne nestandardne formatovanie, vela C++ projektov (napr. Google C++ Style Guide alebo Geant 4) pouziva formatovanie, ktore ma podstatne blizsie k Eclipse Code Style - K&R profile.


 * Eclipse Code Style (K&R built-in profile)
 * + : silny nastroj, detailne nastavenia roznych moznosti, je sucastou samotneho Eclipse
 * - : moze zasadne zmenit formatovanie zdrojoveho kodu (ak je v nesulade s vybranym profilom), nemoznost nastavenia ROOT C++ Coding Conventions


 * Astyle Eclipse C/C++ formatter
 * +</tt> : nerobi zasadne zmeny pri formatovani kodu, moznost nastavenia v sulade s ROOT C++ Coding Conventions
 * -</tt> : nevyvija sa uz dalej (posledna verzia z 2006 roka), a s tym je aj spojene, ze plugin pouziva stary astyle 1.14.1 engine
 * -</tt> : stale sa bude pouzivat Correct Indentation, ktory je spojeny s editorom (built-in Eclipse), a ten je spojeny s built-in Code Style (K&R)

Pravdepodobne docasne pouzivat Astyle Eclipse C/C++ formatter a postupne prejst na standardizovany, moderny Eclipse Code Style - K&R profile

Indentation

 * http://code.google.com/p/google-styleguide/source/browse/trunk/eclipse-cpp-google-style.xml

wget http://gist.github.com/raw/991238/K\&R_mucha.xml

*https://twiki.cern.ch/twiki/bin/view/LHCb/LHCbSoftwareTutorials

Indigo CDT Code Style: K&R &#91;AliRoot&#93; screenshots

Vychadzame z K&R [built-in] profilu, kedze ho budeme menit, musime si vytvorit svoj vlastny profil K&R [mucha]. Na zarovnavanie maju vplyv nastavenia v tychto polozkach:
 * Indentation


 * Tab policy: || align="right" | Spaces only</tt>
 * Indentation size: || align="right" | 2
 * Tab Size: || align="right" | 4
 * }
 * all other items default</tt>, except Statements within 'switch' body and Declarations within 'namespace' definition set as check
 * Braces
 * default (all Brace positions set as Same line</tt>)
 * New Lines
 * default
 * Line Wrapping
 * default
 * Line Wrapping


 * Maximum line width: || align="right" | 120 || (does not affect on indent)
 * Default indentation for wrapped lines: || align="right" | 2
 * Default indentation for initializer lists: || align="right" | 2
 * Never join already wrapped lines || align="right" | uncheck
 * }
 * items with Default indentation</tt> change Indentation policy to Indent on column</tt>
 * Default indentation</tt> &rArr; Indent on column</tt>
 * Expressions (6 items) - do not to change, except Initializer list set Indent by one</tt>
 * items with Default indentation</tt> change Indentation policy to Indent on column</tt>
 * Default indentation</tt> &rArr; Indent on column</tt>
 * Expressions (6 items) - do not to change, except Initializer list set Indent by one</tt>

Eclipse Code Style (K&R built-in profile)
TODO
 * Control Statements
 * in  'if else'  section all items set as check
 * Comments
 * Preserve white space between code and line comments if possible set check

Astyle Eclipse
Astyle Eclipse is based on Astyle program, it aims to provide a C/C++ formatter for CDT plugin in eclipse, so all the supported format optional shall check astyle.

$ su - $ wget http://sourceforge.net/projects/astyleclipse/files/latest/download $ unzip -x astyleclipse*.zip -d /opt/eclipse/
 * Nema zmysel dalej pouzivat, vystaci len Eclipse Indentation, ktore je aj tak nezavisle od Astyle formatovania
 * Manualna instalacia (pre vsetkych uzivatelov)
 * Pomocou Eclipse mechanizmu Help -> Install New Software pridame repository s Location . Plugin sa nainstaluje do user home dir


 * Astyle Eclipse plugin pouziva zastaralu verziu astyle 1.14.1 z roku 2006
 * dnes tuto verziu uz ani nemozno skompilovat, najblizsia kompilovatelna verzia (Fedora 14) je astyle_1.22_linux.tar.gz
 * nastastie manualy na tuto staru verziu astyle su este na webe Artistic Style 1.14.1 alebo man astyle 1.14.1
 * subor zo stranky ROOT C++ Coding Conventions je funkcny pre verziu astyle_1.24_linux.tar.gz
 * Potreba zosuladenia Eclipse Indentation (Eclipse editor + Code Style [K&R]) a Astyle formatovania.

--indent=spaces=2 --one-line=keep-statements --one-line=keep-blocks

Plugins
https://github.com/wangzw/CppStyle http://www.cppstyle.com/


 * http://wiki.eclipse.org/EGit/GitHub/User_Guide


 * http://mihai-nita.net/2013/06/03/eclipse-plugin-external-filter/
 * http://mihai-nita.net/java/


 * https://github.com/jeeeyul/eclipse-themes/
 * http://code.google.com/p/elt/ incubation in http://www.eclipse.org/tm/
 * Local Terminal (Incubation)	0.2.300.201307231220 (general purpose tool)


 * AnyEdit - AnyEdit plugin adds several new tools to the context menu of text- based Eclipse editors, to output consoles, to Eclipse main menu and editor toolbar. AnyEdit contributes also Import/Export working sets wizards
 * Jindent - Jindent is a powerful source code formatter for Java, C and C++ (heavy and ugly)
 * EditBox - Eclipse plugin for highlighting the background of the source code (works with Java code)
 * Eclipse Color Themes - Fresh up your Eclipse with super-awesome color themes!
 * Columns4Eclipse - Columns Plug-in for Eclipse defines the concept of 'Column' and some functions of this editable component. Functions such as copy, paste, cut, fill, lowercase, uppercase, search and replace are provided.
 * cppcheclipse - cppcheclipse is an Eclipse plugin which integrates cppcheck with the CDT project.
 * Linux Tools Project - The Linux Tools project aims to bring a full-featured C and C++ IDE to Linux developers
 * CMake Editor - The CMake Editor is a plug-in to the Eclipse IDE

new (temp)
wget http://gist.github.com/raw/1095765/Indigo_profile_AliRoot.xml wget http://gist.github.com/raw/1095765/Indigo_preferences.epf wget http://gist.github.com/raw/1095765/Indigo_bookmarks.xml

disable scrollbar overlay export GTK_OVERLAY_SCROLLING=0 ano takto funguje, scroll bar uz "nemizne", ale pre vsetky scroll bars, a idealne by bolo len pre hlavny vertikalny, tak ako to funguje v dark theme

V pincipe je to otazka systemu (Fedora/GNOME) a nie samotneho eclipse

eclipse.ini -Dswt.enable.themedScrollBar=true a pre "Dark" themu (preferences->appearance->theme: dark) su nastavenie v subore /opt/eclipse/plugins/org.eclipse.ui.themes_1.2.100.v20180302-1806/css/dark/e4-dark_globalstyle.css napr. tu swt-scrollbar-width: 24px;