Code

text replace
authorbuliabyak <buliabyak@users.sourceforge.net>
Sun, 15 Jul 2007 03:29:51 +0000 (03:29 +0000)
committerbuliabyak <buliabyak@users.sourceforge.net>
Sun, 15 Jul 2007 03:29:51 +0000 (03:29 +0000)
share/extensions/Makefile.am
share/extensions/text_replace.inx [new file with mode: 0644]
share/extensions/text_replace.py [new file with mode: 0644]

index e15df2f3891aa65a362f262967f9d89a8ca676dc..af31e67779cb518edc266cb4f0adeb757db8cd2e 100644 (file)
@@ -88,6 +88,7 @@ extensions = \
        text_titlecase.py \
        text_flipcase.py \
        text_randomcase.py \
+       text_replace.py \
        txt2svg.pl \
        webbrowser_commandline.py \
        webbrowser_faq.py\
@@ -175,6 +176,7 @@ modules = \
        text_titlecase.inx \
        text_flipcase.inx \
        text_randomcase.inx \
+       text_replace.inx \
        txt2svg.inx \
        whirl.inx \
        wmf_input.inx
diff --git a/share/extensions/text_replace.inx b/share/extensions/text_replace.inx
new file mode 100644 (file)
index 0000000..a1e2951
--- /dev/null
@@ -0,0 +1,17 @@
+<inkscape-extension>\r
+       <_name>Replace text...</_name>\r
+       <id>org.inkscape.text.replacetext</id>\r
+       <dependency type="executable" location="extensions">chardataeffect.py</dependency>\r
+       <dependency type="executable" location="extensions">text_replace.py</dependency>\r
+       <param name="from_text" type="string" gui-text="Replace:"></param>
+       <param name="to_text" type="string" gui-text="By:"></param>
+       <effect>\r
+               <object-type>all</object-type>\r
+               <effects-menu>\r
+                       <submenu _name="Text"/>\r
+               </effects-menu>\r
+       </effect>\r
+       <script>\r
+               <command reldir="extensions" interpreter="python">text_replace.py</command>\r
+       </script>\r
+</inkscape-extension>
\ No newline at end of file
diff --git a/share/extensions/text_replace.py b/share/extensions/text_replace.py
new file mode 100644 (file)
index 0000000..3ea6659
--- /dev/null
@@ -0,0 +1,16 @@
+import chardataeffect, inkex, string\r
+\r
+class C(chardataeffect.CharDataEffect):\r
+  def __init__(self):\r
+    chardataeffect.CharDataEffect.__init__(self)\r
+    self.OptionParser.add_option("-f", "--from_text", action="store", type="string", dest="from_text", default="", help="Replace")\r
+    self.OptionParser.add_option("-t", "--to_text", action="store", type="string", dest="to_text", default="", help="by")\r
+             \r
+  def process_chardata(self,text, line, par):\r
+    fr = self.options.from_text.strip('"').replace('\$','$')\r
+    to = self.options.to_text.strip('"').replace('\$','$')\r
+\r
+    return (text.replace(fr, to))\r
+\r
+c = C()\r
+c.affect()\r