|
|
|
NavigationPersonal tools |
E-Coding
[edit] IndentationThe code maintained by raster has an indentation that can't be found anywhere else, except by using the jed editor. [edit] JedThe editor that raster, and other E developers use is called jed. You know it and you may have tried it. If you happen to use this editor, a great way to easily format code to E specs is to modify your ~/.jedrc to include the lines:
% C-mode indentation style
c_set_style ("jed");
% This makes working with .edc files similar to working with code.
% It uses a similar format for the edc also.
add_mode_for_extension("c", "edc");
[edit] Emacsemacs users can use this indentation style: e17-c-style.el
or this
(c-add-style "e" '("gnu" (c-offsets-alist . ((defun-block-intro . 3) (statement-block-intro . 3) (case-label . 1) (statement-case-intro . 3)))))
and set your tab-width to 8 (which is the default anyway) [edit] VimIf you use vim you'll find an indentation line in many files that will help you to correct your code before sending patches.
vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
[edit] IndentIf you don't find your favorite editor above or you already have written some piece of code in a different indentation format, you can use the indent line below.
indent -i3 -bl -bad -nbap -sob -ncdb -di1 -nbc -lp -nce -npcs -sc -ncs -l80
[edit] Edje Source Keyword ColorizationAlso helpful during development is the ability to view the source with keywords highlighted in color. [edit] Emacs edje-mode.elEmacs supports this with the font-lock feature typically via a mode file tailored for the specific language. edje-mode.el by Gustavo Barbieri, with highlight of CPP and more up to date keyword list. [edit] VimTo have syntax highlighting for .edc-files in vim you need a syntax description file. You can find one in cvs (e17/libs/edje/data/edc.vim). Copy (or symlink) this file to ~/.vim/syntax/edc.vim. Now you can switch on syntax highlighting, whenever you edit an .edc-file with: :set filetype=edc Or if preferred you can make the following addition to ~/.vim/filetype.vim: augroup filetypedetect au BufNewFile,BufRead *.edc setfiletype edc augroup END This will allow Vim to detect the .edc extension and automatically set the file type. For Vim 7.0 and newer versions, a vimball with additional syntax highlighting support, as well as indentation and code completion can be downloaded from here: http://www.vim.org/scripts/script.php?script_id=1702 [edit] Coding with SciTESciTE is a very powerful editor, and with some small arrangements you can make it even more useful for your coding sessions with the EFL, adding autocomplete and calltip (with the help on the parameters of functions) and syntax highlighting. [edit] IndentationHere's a brief list of indentation setting: #set the indentation level at 3 spaces indent.size=3 #strips trailing white spaces while saving strip.trailing.spaces=1 [edit] Autocomplete and calltipsScite provides two kinds of autocomplete feature, one that, after pressing Ctrl+Enter, shows a list of words (found in the current file) that start with the character(s) before the cursor, and one based on a file named "API file". Once you set one or more API files, the keybinding Ctrl+Enter work in the same way, while the keybinding Ctrl+I show a list of words found in the file API starting with the characters before the cursor. Moreover, after typed the "(" character the calltip appears, showing a help for the function; the calltip can be invoked by placing the cursor inside the characters "(" and ")" that follows a function call and pressing Ctrl+Shift+Space. [edit] Syntax highlightScite provides a basic syntax highlight for C/C++ keywords using the "keywordclass.cpp" variable in cpp.properties file, and sets "keywords2.$(file.patterns.cpp)" for user-defined keywords, and "keywords3.$(file.patterns.cpp)" for Doxygen keywords; the visual styles are set by "style.cpp.16" for keywords2 and "style.cpp.17" for keywords3. The highlight for EFL keywords can be done adding a words list to "keywords4.$(file.patterns.cpp)", and setting up visual style by "style.cpp.19". [edit] How to build API files and keywords listIn order to build your API file you need ctags and tags2api.py; you also need api2func.py if you want to generate a keywords list for syntax highlight. Here's the sequence to build a tag file for each E library: ctags -f imlib2.tags --excmd=number --c-types=pcdgstue /opt/e17/include/Imlib2.h ctags -f eet.tags --excmd=number --c-types=pcdgstue /opt/e17/include/Eet.h ctags -f evas.tags --excmd=number --c-types=pcdgstue /opt/e17/include/Evas* ctags -f ecore.tags --excmd=number --c-types=pcdgstue /opt/e17/include/Ecore* ctags -f edje.tags --excmd=number --c-types=pcdgstue /opt/e17/include/Edje* ctags -f embryo.tags --excmd=number --c-types=pcdgstue /opt/e17/include/Embryo.h ctags -f epsilon.tags --excmd=number --c-types=pcdgstue /opt/e17/include/Epsilon* ctags -f ewl.tags --excmd=number --c-types=pcdgstue /opt/e17/include/ewl/*.h ctags -f etk.tags --excmd=number --c-types=pcdgstue /opt/e17/include/Etk_Engine_Ecore_Evas* /opt/e17/include/etk/*.h ctags -f emotion.tags --excmd=number --c-types=pcdgstue /opt/e17/include/Emotion.h ctags -f engrave.tags --excmd=number --c-types=pcdgstue /opt/e17/include/engrave/*.h ctags -f efreet.tags --excmd=number --c-types=pcdgstue /opt/e17/include/efreet/*.h Here's an example to build a API file for ETK: python tags2api.py etk.tags > etk.api Having API files, you can copy them into a folder of your choice (to keep my system clean I chose a .scite/api folder tree on my homedir) And here's an example to build a keyword list for highlight: python api2func.py etk.api > etk_func.txt Now we are ready to configure Scite to use API and keywords. Scite provides four properties file used to change settings:
Settings in SciTE.properties overrides those in SciTEDirectory.properties which overrrides those in .SciTEUser.properties which overrides those in SciTEGlobal.properties: you really have the full control of your editor! Using eet's source tree as example, you can have a "SciTE.properties" into libs/eet/src/lib that contains: # Use Eet API file api.*.c=$(SciteUserHome)/.scite/api/eet.api # Eet keywords keywords4.$(file.patterns.cpp)= eet_open eet_close < others here > About keywords, you have to copy the content of eet_func.txt (build before) after "keywords4.$(file.patterns.cpp)=". In this way, you can use only Eet coding stuffs if you're editing a source file into libs/eet/src/lib. To change other settings like fonts, visual styles, or other non project-specific settings you can edit .SciTEUser.properties instead of SciTEGlobal.properties, to avoid to overwrite SciTEGlobal.properties if you upgrade your Scite installation. [edit] DebuggingRead more about how to debug E17 in the article about Debugging. |