1
# -*- coding: utf-8 -*-
3
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
4
#Copyright (c) 2005 Ali Afshar aafshar@gmail.com
6
#Permission is hereby granted, free of charge, to any person obtaining a copy
7
#of this software and associated documentation files (the "Software"), to deal
8
#in the Software without restriction, including without limitation the rights
9
#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
#copies of the Software, and to permit persons to whom the Software is
11
#furnished to do so, subject to the following conditions:
13
#The above copyright notice and this permission notice shall be included in
14
#all copies or substantial portions of the Software.
16
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
import pida.core.service as service
25
import pida.pidagtk.contentview as contentview
29
editor_instance = moo.edit.editor_instance()
30
editor_instance.get_lang_mgr().add_dir('/usr/local/share/moo-1.0/syntax/')
31
editor_instance.get_lang_mgr().read_dirs()
33
class moo_view(contentview.content_view):
37
def init(self, filename=None):
39
self.widget.set_border_width(6)
40
sw = gtk.ScrolledWindow()
41
self.widget.pack_start(sw)
42
self.__editor = editor_instance.create_doc(filename)
47
editor = property(get_editor)
49
class moo_config_view(contentview.content_view):
52
prefs = editor_instance.prefs_page()
54
self.widget.pack_start(prefs)
57
class moo_editor(service.service):
61
multi_view_type = moo_view
62
multi_view_book = 'edit'
64
single_view_type = moo_config_view
65
single_view_book = 'view'
71
def cmd_edit(self, filename=None):
72
if filename not in self.__files:
73
self.__load_file(filename)
74
self.__view_file(filename)
77
#self.__currentview.editor.reload()
80
def __load_file(self, filename):
81
view = self.create_multi_view(filename=filename)
82
self.__files[filename] = view
83
self.__views[view.unique_id] = filename
85
def __view_file(self, filename):
86
self.__currentview = self.__files[filename]
87
self.__files[filename].raise_page()
90
self.get_service('editormanager').events.emit('started')
92
def cmd_goto_line(self, linenumber):
93
self.__currentview.editor.move_cursor(linenumber - 1, 0, True)
96
self.__currentview.editor.save()
99
self.__currentview.editor.undo()
102
self.__currentview.editor.redo()
105
self.__currentview.editor.emit('cut-clipboard')
108
self.__currentview.editor.emit('copy-clipboard')
111
self.__currentview.editor.emit('paste-clipboard')
113
def act_editor_preferences(self, action):
114
self.create_single_view()
116
def cb_multiview_closed(self, view):
117
if view.unique_id in self.__views:
118
filename = self.__views[view.unique_id]
119
self.boss.call_command('buffermanager', 'file_closed',
122
def get_menu_definition(self):
125
<menu name="base_tools" action="base_tools_menu">
127
<menuitem name="mooconf" action="mooedit+editor_preferences" />