summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Andreoli <dave@gurumeditation.it>2017-02-26 20:47:41 +0100
committerDave Andreoli <dave@gurumeditation.it>2017-02-26 20:47:41 +0100
commita1fab73a7e039c7a1a62b741a2ac60b3b53fbcb3 (patch)
tree7890f0f8f5d6c8878a3209560d79b2bfdad1d825
parenta998a9f2f1043103e4710a4b701d168f046fe823 (diff)
Add a simple multiline snippets parserHEADmaster
Just a tiny utils that give you the ability to write geany snippets using a multiline syntax
-rw-r--r--snippets.conf19
-rw-r--r--snippets.multiline.conf284
-rwxr-xr-xsnippets_multiline_parser.py42
3 files changed, 341 insertions, 4 deletions
diff --git a/snippets.conf b/snippets.conf
index 3e7132d..b0aea7f 100644
--- a/snippets.conf
+++ b/snippets.conf
@@ -10,18 +10,29 @@
10# 10#
11# NOTE: default snippets file (with docs) at: /usr/share/geany/snippets.conf 11# NOTE: default snippets file (with docs) at: /usr/share/geany/snippets.conf
12# 12#
13# NOTE: the final snippets.conf file is generated from the
14# snippets.multiline.conf one. Just run the snippets_multiline_parser.py
15# script to regenerate.
16#
13 17
14[Python] 18[Python]
15# generic python 19### generic python
16prop=@property\ndef %cursor%(self):\n\treturn 20prop=@property\ndef %cursor%(self):\n\treturn\n
17class=class %cursor%(object):\n\tdef __init__(self):\n\t\tpass 21class=class %cursor%(object):\n\tdef __init__(self):\n\t\tpass\n
18
19 22
20# Python-EFL 23# Python-EFL
21expand=size_hint_expand=EXPAND_BOTH 24expand=size_hint_expand=EXPAND_BOTH
22fill=size_hint_fill=FILL_BOTH 25fill=size_hint_fill=FILL_BOTH
23align=size_hint_align=(0.0,0.5) 26align=size_hint_align=(0.0,0.5)
24 27
28[Cython]
29# Sphyix
30since=.. versionadded:: 1.%cursor%
31
32# Python-EFL
33propbool=property %cursor%:\n\t""" TODOC\n\n\tTODOC\n\n\t:type: TODOC\n\n\t.. versionadded:: TODOC\n\n\t"""\n\tdef __get__(self):\n\t\treturn bool(XXXXXX_get(self.obj))\n\n\tdef __set__(self, bint value):\n\t\tXXXXXX_set(self.obj, value)\n\ndef XXXXXX_get(self):\n\treturn bool(XXXXXX_get(self.obj))\ndef XXXXXX_set(self, bint value):\n\tXXXXXX_set(self.obj, value)\n
34
35
25[Edje] 36[Edje]
26# blocks 37# blocks
27collections=collections {\n\t%cursor% \n} 38collections=collections {\n\t%cursor% \n}
diff --git a/snippets.multiline.conf b/snippets.multiline.conf
new file mode 100644
index 0000000..3bc32c1
--- /dev/null
+++ b/snippets.multiline.conf
@@ -0,0 +1,284 @@
1#
2# EFL snippets definition for the Geany editor
3#
4# Usage:
5#
6# If you do NOT have other custom snippets:
7# Copy this file to "~/.config/geany/" (or just link it)
8#
9# Otherwise you need to copy/paste the snippets here to your file.
10#
11# NOTE: default snippets file (with docs) at: /usr/share/geany/snippets.conf
12#
13# NOTE: the final snippets.conf file is generated from the
14# snippets.multiline.conf one. Just run the snippets_multiline_parser.py
15# script to regenerate.
16#
17
18[Python]
19### generic python
20prop=MULTILINE
21# @property
22# def %cursor%(self):
23# return
24class=MULTILINE
25# class %cursor%(object):
26# def __init__(self):
27# pass
28
29# Python-EFL
30expand=size_hint_expand=EXPAND_BOTH
31fill=size_hint_fill=FILL_BOTH
32align=size_hint_align=(0.0,0.5)
33
34[Cython]
35# Sphyix
36since=.. versionadded:: 1.%cursor%
37
38# Python-EFL
39propbool=MULTILINE
40# property %cursor%:
41# """ TODOC
42#
43# TODOC
44#
45# :type: TODOC
46#
47# .. versionadded:: TODOC
48#
49# """
50# def __get__(self):
51# return bool(XXXXXX_get(self.obj))
52#
53# def __set__(self, bint value):
54# XXXXXX_set(self.obj, value)
55#
56# def XXXXXX_get(self):
57# return bool(XXXXXX_get(self.obj))
58# def XXXXXX_set(self, bint value):
59# XXXXXX_set(self.obj, value)
60
61
62[Edje]
63# blocks
64collections=collections {\n\t%cursor% \n}
65group=group { name: "%cursor%";\n\tparts {\n\t}\n}
66parts=parts {\n\t%cursor% \n}
67rel1=rel1 {\n\tto: "%cursor%";\n\trelative: 0.0 0.0;\n\toffset: 0 0;\n}
68rel2=rel2 {\n\tto: "%cursor%";\n\trelative: 1.0 1.0;\n\toffset: -1 -1;\n}
69fill=fill {\n\tsmooth: 1;\n\ttype: TILE;\n\torigin {\n\t\trelative: %cursor%0.0 0.0;\n\t\toffset: 0 0;\n\t}\n\tsize {\n\t\trelative: 1.0 1.0;\n\t\toffset: -1 -1;\n\t}\n}
70origin=origin {\n\trelative: 0.0 0.0;\n\toffset: 0 0;\n}
71text=text {\n\ttext: "";\n\tfont: "%cursor%";\n\tsize: 12;\n\ttext_class: "";\n\tmin: 1 0;\n\tellipsis: -1;\n}
72script=script {\n\t%cursor%\n}
73
74# parts
75part=part { name: "%cursor%"; type: RECT;\n\tdescription { state: "default" 0.0;\n\t\t\n\t}\n}
76RECT=part { name: "%cursor%"; type: RECT;\n\tdescription { state: "default" 0.0;\n\t}\n}
77IMAGE=part { name: "%cursor%"; type: IMAGE;\n\tdescription { state: "default" 0.0;\n\t\timage {\n\t\t\tnormal: "";\n\t\t\tborder: left right top bottom;\n\t\t}\n\t}\n}
78
79# colors
80color_class=color_class {\n\tname: "%cursor%";\n\tcolor: 200 200 200 255;\n\tcolor2: 200 200 200 255;\n\tcolor3: 200 200 200 255; \n}
81
82# text styles
83styles=styles {\n\t%cursor%\n}
84style=style {\n\tname: "%cursor%";\n\tbase: "font=Sans font_size=12 color=#fff wrap=word";\n\ttag: "b" "+ font_weight=Bold";\n}
85base=base: "font=%cursor%Sans font_size=12 color=#fff wrap=word";
86tag=tag: "%cursor%b" "+ font_weight=Bold";
87
88# externals
89externals=externals {\n\texternal: "%cursor%";\n}
90external=external: "%cursor%";
91
92# sounds
93sounds=sounds {\n\t%cursor%\n}
94sample=sample {\n\tname: "%cursor%" COMP;\n\tsource: "sound_file.wav";\n}
95tone=tone: "%cursor%" 440;
96vibrations=vibrations {\n\t%cursor% \n}
97
98# images
99images=images {\n\timage: "%cursor%.png" COMP;\n}
100image=image: "%cursor%.png" COMP;
101border=border: %cursor%left right top bottom;
102size=size: %cursor%minw minh maxw maxh;
103border_scale_by=border_scale_by: %cursor%0.0;
104set=set {\n\tname: "%cursor%";\n\timage {\n\t\timage: "filename1.png" LOSSY 90;\n\t\tsize: minw minh maxw maxh;\n\t}\n\timage {\n\t\timage: "filename2.png" LOSSY 90;\n\t\tsize: minw minh maxw maxh;\n\t}\n}
105
106# fonts
107fonts=fonts {\n\tfont: "%cursor%.otf" "FontAlias";\n}
108font=font: "%cursor%.otf" "FontAlias";
109
110
111# data
112data=data {\n\titem: "%cursor%key" "value";\n\tfile: "key" "filename.ext"\n}
113item=item: "%cursor%key" "value";
114file=file: "%cursor%key" "filename.ext";
115
116# collections
117base_scale=base_scale: %cursor%1.0;
118
119# group
120inherit_only=inherit_only: %cursor%1;
121target_group=target_group: "%cursor%" "%cursor%" "%cursor%";
122script_only=script_only: %cursor%on;
123script_recursion=script_recursion: %cursor%1;
124alias=alias: "%cursor%";
125min=min: %cursor%width height;
126max=max: %cursor%width height;
127broadcast_signal=broadcast_signal: on;
128orientation=orientation: LTR;
129program_source=program_source: "%cursor%";
130# group.limits
131limits=limits {\n\tvertical: "%cursor%" height_barrier;\n\thorizontal: "limit_name" width_barrier;\n}
132vertical=vertical: "%cursor%" height_barrier;
133horizontal=horizontal: "%cursor%" width_barrier;
134
135# part
136type=type: %cursor%RECT;
137program_remove=program_remove: "%cursor%" "%cursor%" "%cursor%";
138part_remove=part_remove: "%cursor%" "%cursor%" "%cursor%";
139physics_body=%cursor%RIGID_BOX;
140insert_before=insert_before: "%cursor%";
141insert_after=insert_after: "%cursor%";
142mouse_events=mouse_events: 0;\n
143repeat_events=repeat_events: 1;\n
144scale=scale: 1;\n
145ignore_flags=ignore_flags: ON_HOLD;\n
146pointer_mode=pointer_mode: NOGRAB;\n
147precise_is_inside=precise_is_inside: 1;\n
148use_alternate_font_metrics=use_alternate_font_metrics: 1;\n
149clip_to=clip_to: "%cursor%";
150source=source: "%cursor%";
151source2=source2: "%cursor%";
152source3=source3: "%cursor%";
153source4=source4: "%cursor%";
154source5=source5: "%cursor%";
155source6=source6: "%cursor%";
156effect=effect: %cursor%SHADOW;
157entry_mode=entry_mode: %cursor%EDITABLE;
158select_mode=select_mode: %cursor%EXPLICIT;
159cursor_mode=cursor_mode: %cursor%BEFORE;
160multiline=multiline: 0;\n
161access=access: 1;\n
162
163name=name: "%cursor%";
164color=color: 200 200 200 255;
165color2=color2: 200 200 200 255;
166color3=color3: 200 200 200 255;
167
168# description
169description=description { state: "%cursor%" 0.0;\n\t\n}
170desc=description { state: "%cursor%" 0.0;\n\t\n}
171inherit=inherit: "%cursor%default" 0.0;
172state=state: "%cursor%" 0.0;
173visible=visible: 0;\n
174limit=limit: %cursor%;
175align=align: %cursor%0.0 0.0;
176fixed=fixed: 1 1;\n
177minmul=minmul: %cursor%1.0 1.0;
178step=step: %cursor%0 0;
179aspect=aspect: %cursor%vmin vmax;\naspect_preference: BOTH;
180aspect_preference=aspect_preference: BOTH;\n
181offset=offset: %cursor%0 0;
182to=to: "%cursor%";
183to_x=to_x: "%cursor%";
184to_y=to_y: "%cursor%";
185normal=normal: "%cursor%.png" COMP;
186tween=tween: "%cursor% .png";
187middle=middle: NONE;\n
188border_scale=border_scale: 1;\n
189scale_hint=scale_hint: %cursor%STATIC;
190ellipsis=ellipsis: -1;
191repch=repch: "%cursor%*";
192size_range=size_range: 1.2 1.2;
193fit=fit: 1 0;
194text_source=text_source: "%cursor%";
195filter=filter: "%cursor%";
196
197# dragable
198dragable=dragable {\n\tconfine: "%cursor%";\n\tevents: "another dragable part";\n\tx: 0 0 0;\n\ty: 0 0 0;\n}
199x=x: 1 0 0;\n
200y=y: 1 0 0;\n
201confine=confine: "%cursor%";
202threshold=threshold: "%cursor%";
203events=events: "%cursor%";
204relative=relative: %cursor%0.0 0.0;
205
206# box/table
207box=box {\n\tlayout: "%cursor%vertical";\n\tpadding: 0 2;\n\talign: 0.5 0.5;\n\tmin: 0 0;\n\titems {\n\t\titem {\n\t\t\ttype: GROUP;\n\t\t\tsource: "";\n\t\t}\n\t}\n}
208table=table {\n\thomogeneous: TABLE;\n\tpadding: 0 2;\n\talign: 0.5 0.5;\n\tmin: 0 0;\n\titems {\n\t\t%cursor%\n\t}\n}
209layout=layout: "%cursor%";
210homogeneous=homogeneous: %cursor%TABLE;
211padding=padding: %cursor%0 0;
212# box/table items
213spread=spread: %cursor%width height;
214prefer=prefer: %cursor%width height;
215# padding=padding: %cursor%left right top bottom; (collide)
216position=position: %cursor%col row;
217span=span: %cursor%col row;
218weight=weight: %cursor%x_val y_val;
219
220# map
221center=center: "%cursor%";
222alpha=alpha: 1;
223perspective_on=perspective_on: 1;
224smooth=smooth: 1;
225on=on: 1;
226light=light: "%cursor%";
227perspective=perspective: "%cursor%";
228center=center: "%cursor%";
229backface_cull=backface_cull: 1;
230perspective=perspective {\n\tzplane: 0;\n\tfocal: 1000;\n}
231zplane=zplane: %cursor%;
232focal=focal: %cursor%;
233
234# physics (obj)
235physics=physics {\n\tignore_part_pos: 1;\n\tmass: %cursor%5.31;\n\tfriction: 0.5;\n\trestitution: 0.82;\n\tdamping: 0.4 0.24;\n\tsleep: 32 18.9;\n\tmaterial: IRON;\n\tdensity: 3.2;\n\thardness: 0.42;\n\tlight_on: 1;\n\tz: -15;\n\tdepth: 30;\n\tmovement_freedom { }\n\tfaces { }\n}
236mass=mass: %cursor%;
237restitution=restitution: %cursor%;
238friction=friction: %cursor%;
239ignore_part_pos=ignore_part_pos: %cursor%0;
240damping=damping: %cursor%linear angular;
241sleep=sleep: %cursor%linear angular;
242material=material: %cursor%CONCRETE;
243density=density: %cursor%;
244hardness=hardness: %cursor%;
245light_on=light_on: 1;
246z=z: %cursor%;
247depth=depth: %cursor%;
248backface_cull=backface_cull: 1;
249movement_freedom=movement_freedom {\n\tlinear: %cursor%1 1 0;\n\tangular: 0 0 1;\n}
250linear=linear: %cursor%1 1 0;
251angular=angular: %cursor%0 0 1;
252faces=faces {\n\tface {\n\t\ttype: BOX_FRONT;\n\t\tsource: "%cursor%";\n\t}\n}
253face=face {\n\ttype: BOX_FRONT;\n\tsource: "%cursor%";\n}
254# physics (world)
255world=world {\n\tgravity: 0 294 0;\n\trate: 30;\n\tz: -50;\n\tdepth: 100;\n}
256gravity=gravity: %cursor%0 0 0;
257rate=rate: %cursor%30;
258depth=depth: %cursor%100;
259#z=z: %cursor%-50; (collide)
260
261# external params
262params=params {\n\t%cursor%\n}
263int=int: "%cursor%" 0;
264double=double: "%cursor%" 0.0;
265string=string: "%cursor%" "%cursor%";
266bool=bool: "%cursor%" 1;
267choice=choice: "%cursor%" "%cursor%";
268
269# programs
270link=link {\n\tbase: "edje,signal" "edje";\n\ttransition: LINEAR 0.2;\n\tin: 0.5 0.1;\n\tafter: "some_program";\n}
271programs=programs {\n\tprogram { name: "%cursor%";\n\t\tsignal: "";\n\t\tsource: "";\n\t\taction: STATE_SET "default" 0.0;\n\t\ttransition: LINEAR 1.0;\n\t\ttarget: "";\n\t}\n}
272program=program { name: "%cursor%";\n\tsignal: "";\n\tsource: "";\n\taction: STATE_SET "default" 0.0;\n\ttransition: LINEAR 1.0;\n\ttarget: "";\n}
273prog=program { name: "%cursor%";\n\tsignal: "";\n\tsource: "";\n\taction: STATE_SET "default" 0.0;\n\ttransition: LINEAR 1.0;\n\ttarget: "";\n}
274sequence=sequence {\n\t%cursor% \n}
275signal=signal: "%cursor%";
276source=source: "%cursor%";
277filter=filter: "%cursor%" "%cursor%";
278in=in: %cursor%1.0 0.0;
279action=action: STATE_SET "%cursor%" 0.0;
280transition=transition: LINEAR 1.0;
281target=target: "%cursor%";
282target_groups=target_groups: "%cursor%" "%cursor%";
283after=after: "%cursor%";
284api=api: "%cursor%" "%cursor%";
diff --git a/snippets_multiline_parser.py b/snippets_multiline_parser.py
new file mode 100755
index 0000000..ce5e498
--- /dev/null
+++ b/snippets_multiline_parser.py
@@ -0,0 +1,42 @@
1#!/usr/bin/env python
2#
3# Simple parser to generate snippets.conf file from the snippets.multiline.conf
4# template.
5# In the template you can write multiline snippets, that will be single-lined
6# by running this generator.
7#
8# Look at the existing template fiel to see the supported syntax.
9#
10
11TEMPLATE = 'snippets.multiline.conf'
12OUTPUT = 'snippets.conf'
13
14MODE_SEARCH = 0
15MODE_INSIDE = 1
16
17mode = MODE_SEARCH
18
19with open(TEMPLATE,'r') as infile, open(OUTPUT,'w') as outfile:
20 for line in infile:
21
22 if mode == MODE_INSIDE:
23 if line.startswith('# '):
24 # print("+", line)
25 escaped = line[2:]
26 escaped = escaped.replace('\n', '\\n')
27 escaped = escaped.replace('\t', '\\t')
28 escaped = escaped.replace(' ', '\\t')
29 outfile.write(escaped)
30 else:
31 # print("END", line)
32 outfile.write('\n')
33 mode = MODE_SEARCH
34
35 if mode == MODE_SEARCH:
36 if line.endswith('=MULTILINE\n'):
37 # print("START", line)
38 outfile.write(line.replace('MULTILINE\n', ''))
39 mode = MODE_INSIDE
40 else:
41 outfile.write(line)
42