中村です。

call for scripts の一環としまして、
Netscape に URL を送り込むスクリプトを
書いてみました。

Netscape 3.04 で動作を確認しました。
Netscpae 4.x でも -remote オプション
使えるかは知りません。

問題点
○ Tcl/Tk から値を受け取る方法が良く分かっていない
○ class とはしたものの意味がない…
○ url を取得する正規表現がダメ
   (どう書けば良いか良く話には出ると思うのですが、
   良くおぼえていないから)

では、ご賞味ください

#!/usr/local/bin/ruby
#
# ./send_mozilla.rb < file
#
# from 1998.03.03

require "tk"

root = Tk.root
root.title("Send URL to Mozilla")
root.iconname("Send URL")

class SendURL < TkWindow
  def initialize
	super
	TkFrame.new {|frame|
	  $list = TkListbox.new(frame) {
		yscroll proc{|idx|
		  $scroll.set *idx
		}
		setgrid 1
		width 80
		height 12
		pack('side' => 'left', 'expand' => 1, 'fill' => 'both')
	  }
	  $scroll = TkScrollbar.new(frame) {
		command proc{|idx|
		  $list.yview *idx
		}
		pack('side' => 'right', 'fill' => 'y')
	  }
	  borderwidth '.5c'
	  pack('side' => 'top', 'expand' => 'yes', 'fill' => 'y')
	}
	$list.bind "Double-1", proc {
	  # ここら辺も?
	  var = TkVariable.new
	  id = var.id
	  INTERP._eval('eval {global '+id+';'+
				   'set ' + id + ' [selection get]}')
	  str = "netscape -remote 'openURL(" + var.value + ")'"
	  print str, "\n"
	  system str
	}
  end
  def insert(url)
	for i in url
	  $list.insert 'end', i
	end
  end
end


url = []

while gets
# これは絶対まともなのに直す必要あり
  if /((http|ftp):\/\/.+) /
	url.push($1)
  end
end

mozilla = SendURL.new
mozilla.insert(url)

Tk.mainloop

       中村典嗣  E-mail: nnakamur / mxq.meshnet.or.jp