aMSN Forums
May 18, 2013, 07:50:32 pm *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: New forum for aMSN !!
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: New plugin for searching in the diccionary.  (Read 2105 times)
Zaskar
Super Power User
**
Offline Offline

Posts: 159


View Profile
« on: January 03, 2006, 06:55:44 am »

Hello everybody... This is the first time I write here.

First of all, I speak spanish, I'm from Argentina, and I found "in google" a little script for Linux that searchs word in a spanish diccionary (Real Academia Española) using lynx. I don't know anything about TCL, but I saw the plugin WhatIs, and I wanted to do something like this for searching in that dictionary. The result, I had readen the Jasper Huzen's code and I have copied a few lines to my/his plugin, and it's working know.
The reason why I'm writting here is because I wanted to  share this with other people who may find this usefull, but I don't know where to send it, so, here it is:

-----begin of drae.tcl-----------------------------------------------------------------------------------
# Basado en el plugin "WhatIs" de Jasper Huzen
namespace eval ::drae {
        proc init { dir }       {
                ::plugins::RegisterPlugin "drae"
                ::plugins::RegisterEvent "drae" new_chatwindow addButtons
                plugins_log "drae" "plugin registered"
        }

        proc getSelectedText { w } {
           if { $::version == "0.94" } {
                        set window $w.f.bottom.in.input

                        if { [ catch {$window tag ranges sel}]} {
                                set window $w
                        }

                        set index [$window tag ranges sel]

                        if { $index == "" } {
                                set window $w.f.out.text
                                catch {set index [$window tag ranges sel]}
                                if { $index == "" } {  return }
                        }
                } else {
                        if { [ catch {set window [::ChatWindow::GetInputText $w]} ]} {
                                set window $w
                        }

                        set index [$window tag ranges sel]

                        if { $index == "" } {
                                set window [::ChatWindow::GetOutText $w]
                                catch {set index [$window tag ranges sel]}
                                if { $index == "" } {  return }
                        }
                }

                set dump [$window dump -text [lindex $index 0] [lindex $index 1]]

                if { $dump == "" } return

                foreach { text output index } $dump {
                        append tpmVar $output
                }
                return $tpmVar
        }

        proc addButtons { event evpar } {
                upvar 2 $evpar args
                plugins_log "drae" "Add buttons to window"
                set w $args(win)
                set copymenu $w.copy
                $copymenu add command -label "Diccionario RAE" -command "drae::drae $w"
        }

        proc drae { w } {
                set searchText [getSelectedText $w]
                if { $searchText == "" } {
                        ::amsn::messageBox "No text selected!" ok error
                } else {
                        set searchText [string tolower $searchText]
                        catch {exec lynx --dump --nolist http://buscon.rae.es/draeI/SrvltGUIBusUsual?TIPO_HTML=2&LEMA=$searchText} output
                        ::amsn::WinWrite [::ChatWindow::Name $w] "\n" green
                        if { $::version == "0.94" } {
                                        ::amsn::WinWrite [::ChatWindow::Name $w] "--------------------------------------------------" gray_italic
                        } else {
                                        ::amsn::WinWriteIcon [::ChatWindow::Name $w] greyline 3
                        }
                        ::amsn::WinWrite [::ChatWindow::Name $w] "\n$output\n" gray
                        if { $::version == "0.94" } {
                                        ::amsn::WinWrite [::ChatWindow::Name $w] "--------------------------------------------------\n" gray_italic
                        } else {
                                        ::amsn::WinWriteIcon [::ChatWindow::Name $w] greyline 3
                        }
                }
        }

        proc deInit { } {
                ::plugins::UnRegisterEvents "drae"
                plugins_log "drae" "plugin unregistered"
        }
}
-----end of drae.tcl-----------------------------------------------------------------------------------

-----begin of plugininfo.xml-----------------------------------------------------------------------------------
<?xml version="1.0"?>
<plugin>
       <name>drae</name>
       <author>Pablo Novara (and Jasper Huzen)</author>
       <description>Busca la definicion del texto seleccionado en el diccionario de la Real Academia Española</description>
       <amsn_version>0.94</amsn_version>
       <plugin_version>1.0</plugin_version>
       <plugin_file>drae.tcl</plugin_file>
       <plugin_namespace>drae</plugin_namespace>
       <init_procedure>init</init_procedure>
                 <deinit_procedure>deInit</deinit_procedure>
</plugin>
-----end of plugininfo.xml-----------------------------------------------------------------------------------

So, if somebody like this idea can tell me what to do, or where to send that little code... The only problem is that it's only for Spanish speaking people.
Thanks anyway. And happy new year!

P.S.: does anybody knows Jasper (WhatIs Plugin's author) ?... Say thanks to him for the code Wink.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!