
我正在使用帶有奇怪字體的 gedit,這些字體有時會相互覆蓋。我可以更改行間距嗎?
答案1
外部工具外掛程式可以幫助更改行之間的間距。
具體來說,它透過幫助您在工作文件上執行腳本以及允許 gedit 與電腦上的其他程式互動來擴展 gedit。
若要啟用外部工具插件,請選擇:
Gedit ---- 選項 ---- 插件 ---- 外部工具。
啟用插件後,您需要對其進行配置以滿足您的需求。
可透過選擇以下選項來使用設定選項:
工具 ---- 管理外部工具。
需要有效使用腳本的知識。
將出現一個對話框,您可以開始新增工具。
要運行工具,請前往:
工具 ---- 外部工具或使用關聯的快速鍵(如果適用)。
工具的儲存和手動編輯:/usr/share/gedit/plugins/externaltools/tools。
Gedit 的 LineSpacing 外掛程式範例:
http://natural966.wordpress.com/2012/08/19/my-linespacing-plugin-for-gedit-3/
並由兩個文件組成:
行間距.插件:
[Plugin]
Loader=python
Module=linespacing
IAge=3
Name=Line-spacing
Description=Increase or decrease space between lines
Authors=
Copyright=
Website=
行距.py:
from gi.repository import GObject, Gtk, Gedit
UI_XML = """<ui>
<menubar name="MenuBar">
<menu name="ToolsMenu" action="Tools">
<placeholder name="ToolsOps_3">
<menuitem name="LineSpacingAction0" action="LineSpacingAction0"/>
<menuitem name="LineSpacingAction1" action="LineSpacingAction1"/>
<menuitem name="LineSpacingAction2" action="LineSpacingAction2"/>
</placeholder>
</menu>
</menubar>
</ui>"""
class LineSpacing(GObject.Object, Gedit.WindowActivatable):
__gtype_name__ = "LineSpacing"
window = GObject.property(type=Gedit.Window)
def __init__(self):
GObject.Object.__init__(self)
def _add_ui(self):
manager = self.window.get_ui_manager()
self._actions = Gtk.ActionGroup("LineSpacingActions")
self._actions.add_actions([
('LineSpacingAction0', Gtk.STOCK_INFO, "Reset Line spacing",
"<Control><Alt>0", "Reset Line spacing",
self.on_linespacing_action_activate0),
('LineSpacingAction1', Gtk.STOCK_INFO, "Decrease Line spacing",
"<Control><Alt>8", "Decrease Line spacing",
self.on_linespacing_action_activate1),
('LineSpacingAction2', Gtk.STOCK_INFO, "Increase Line spacing",
"<Control><Alt>9", "Increase Line spacing",
self.on_linespacing_action_activate2),
])
manager.insert_action_group(self._actions)
self._ui_merge_id = manager.add_ui_from_string(UI_XML)
manager.ensure_update()
def do_activate(self):
self._add_ui()
def do_deactivate(self):
self._remove_ui()
def do_update_state(self):
pass
def on_linespacing_action_activate0(self, action, data=None):
view = self.window.get_active_view()
if view:
view.set_pixels_below_lines(0)
view.set_pixels_inside_wrap(0)
def on_linespacing_action_activate1(self, action, data=None):
view = self.window.get_active_view()
if view:
if view.get_pixels_below_lines() >= 0:
view.set_pixels_below_lines(view.get_pixels_below_lines() - 1)
if view.get_pixels_inside_wrap() >= 0:
view.set_pixels_inside_wrap(view.get_pixels_inside_wrap() - 1)
def on_linespacing_action_activate2(self, action, data=None):
view = self.window.get_active_view()
if view:
view.set_pixels_below_lines(view.get_pixels_below_lines() + 1)
view.set_pixels_inside_wrap(view.get_pixels_inside_wrap() + 1)
def _remove_ui(self):
manager = self.window.get_ui_manager()
manager.remove_ui(self._ui_merge_id)
manager.remove_action_group(self._actions)
manager.ensure_update()
資料來源:
http://natural966.wordpress.com/2012/08/19/my-linespacing-plugin-for-gedit-3/
http://www.micahcarrick.com/writing-plugins-for-gedit-3-in-python.html
https://wiki.gnome.org/Projects/Vala/Gedit3PluginSample
答案2
我為 gedit 3 製作了一個用於行間距的小插件
下載'linespaces.plugin'和'linespaces.py',並將它們移到'~/.local/share/gedit/plugins/'
在“linespaces.py”中設定“像素”
運行gedit
到首選項 -> 外掛程式 -> 選擇行間距