Permalink
Browse files

Allow the user to configure IRB's prompts and path

  • Loading branch information...
1 parent 033941c commit b43b299afea9bea9b04800932127e8b922b8288c @stcrocco committed Oct 16, 2011
Showing with 154 additions and 0 deletions.
  1. +31 −0 plugins/irb/irb.rb
  2. +123 −0 plugins/irb/ui/irb_config_widget.ui
View
@@ -20,6 +20,7 @@
require 'irb/irb_controller'
require_relative 'ui/irb_tool_widget'
+require_relative 'ui/irb_config_widget'
module Ruber
@@ -77,6 +78,11 @@ def stop
@controller.stop_irb
end
+ def load_settings
+ @controller.prompts = Ruber[:config][:irb, :prompts]
+ end
+ slots :load_settings
+
private
def display_output lines
@@ -104,6 +110,31 @@ def send_to_irb line
class ConfigWidget < Qt::Widget
+ def initialize parent = nil
+ super
+ @ui = Ui::ConfigWidget.new
+ @ui.setup_ui self
+ end
+
+ def read_settings
+ prompts = @settings_dialog.container[:irb, :prompts]
+ @ui.prompt_i.text = prompts[:PROMPT_I]
+ @ui.prompt_n.text = prompts[:PROMPT_N]
+ @ui.prompt_s.text = prompts[:PROMPT_S]
+ @ui.prompt_c.text = prompts[:PROMPT_C]
+ @ui.prompt_return.text = prompts[:RETURN]
+ end
+
+ def store_settings
+ prompts = {}
+ prompts[:PROMPT_I] = @ui.prompt_i.text
+ prompts[:PROMPT_N] = @ui.prompt_n.text
+ prompts[:PROMPT_S] = @ui.prompt_s.text
+ prompts[:PROMPT_C] = @ui.prompt_c.text
+ prompts[:RETURN] = @ui.prompt_return.text
+ @settings_dialog.container[:irb, :prompts] = prompts
+ end
+
end
end
@@ -0,0 +1,123 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Ruber::IRB::ConfigWidget</class>
+ <widget class="QWidget" name="Ruber::IRB::ConfigWidget">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>217</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QFormLayout" name="formLayout_2">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_6">
+ <property name="text">
+ <string>&amp;IRB path</string>
+ </property>
+ <property name="buddy">
+ <cstring>_irb__irb</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="KUrlRequester" name="_irb__irb"/>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox">
+ <property name="title">
+ <string>IRB Prompt</string>
+ </property>
+ <layout class="QFormLayout" name="formLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>&amp;Normal prompt</string>
+ </property>
+ <property name="buddy">
+ <cstring>prompt_i</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="KLineEdit" name="prompt_i"/>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>&amp;Indent prompt</string>
+ </property>
+ <property name="buddy">
+ <cstring>prompt_n</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="KLineEdit" name="prompt_n"/>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>&amp;String prompt</string>
+ </property>
+ <property name="buddy">
+ <cstring>prompt_s</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="KLineEdit" name="prompt_s"/>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="label_4">
+ <property name="text">
+ <string>&amp;Continue prompt</string>
+ </property>
+ <property name="buddy">
+ <cstring>prompt_c</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="KLineEdit" name="prompt_c"/>
+ </item>
+ <item row="4" column="0">
+ <widget class="QLabel" name="label_5">
+ <property name="text">
+ <string>&amp;Return prompt</string>
+ </property>
+ <property name="buddy">
+ <cstring>prompt_return</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1">
+ <widget class="KLineEdit" name="prompt_return">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>KUrlRequester</class>
+ <extends>QFrame</extends>
+ <header>kurlrequester.h</header>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>

0 comments on commit b43b299

Please sign in to comment.