2010年8月27日金曜日

SharpDevelop+IronRuby menustripのbug?



menustripにてshortcutkey[Ctrl+O]を設定すると、[ソース]から[デザイン]にすると以下のエラーが出る。

デザイナのロードに失敗。ソースコードのシンタックスエラーと参照が正しいかをチェックしてください
ICSharpCode.FormsDesigner.FormsDesignerLoadException: System.ComponentModel.InvalidEnumArgumentException: 引数値 'value' (79) は列挙型 'Keys' に対して無効です。
ソースコードのShortcutKeysを
@openOToolStripMenuItem.ShortcutKeys = System::Windows::Forms::Keys.Control System::Windows::Forms::Keys.O
OとControlを入れ替える。
@openOToolStripMenuItem.ShortcutKeys = System::Windows::Forms::Keys.O System::Windows::Forms::Keys.Control
[デザイン]画面ではCtrl+LButtonと表示されるが、実行するとCtrl+Oと表示される。

2010年8月4日水曜日

ruby1.8.7+qtruby4


ruby 1.8.7 (2010-06-23 patchlevel 299) [i386-mingw32]
C:\Documents and Settings\..>gem install qtruby4
Building native extensions. This could take a while...ERROR: Error installing qtruby4: ERROR: Failed to build gem native extension.
rake RUBYARCHDIR=C:/ruby/Ruby187/lib/ruby/gems/1.8/gems/qtruby4-2.1.0-x86-mswin32/lib RUBYLIBDIR=C:/ruby/Ruby187/lib/ruby/gems/1.8/gems/qtruby4-2.1.0-x86-mswin32/lib'rake' は、内部コマンドまたは外部コマンド、操作可能なプログラムまたはバッチ ファイルとして認識されていません。
Gem files will remain installed in C:/ruby/Ruby187/lib/ruby/gems/1.8/gems/qtruby4-2.1.0-x86-mswin32 for inspection.Results logged to C:/ruby/Ruby187/lib/ruby/gems/1.8/gems/qtruby4-2.1.0-x86-mswin32/gem_make.out
C:\Documents and Settings\..>gem install
rake
Successfully installed rake-0.8.71 gem installedInstalling ri documentation for rake-0.8.7...Installing RDoc documentation for rake-0.8.7...
C:\Documents and Settings\..>gem install qtruby4
Building native extensions. This could take a while...Successfully installed qtruby4-2.1.0-x86-mswin321 gem installedInstalling ri documentation for qtruby4-2.1.0-x86-mswin32...Installing RDoc documentation for qtruby4-2.1.0-x86-mswin32...
C:\Documents and Settings\..>gem list
*** LOCAL GEMS ***
qtruby4 (2.1.0 mswin32)
rake (0.8.7)
C:\Documents and Settings\..>
#hello_utf8n.rb
#!/usr/bin/env ruby -Ku
require 'rubygems'
require 'Qt4'
app = Qt::Application.new(ARGV)
label = Qt::Label.new("ハロー Qt!")
label.show()
app.exec()
C:\Documents and Settings\..>ruby hello_utf8n.rb


Ruby pik update  (pik-0.2.8)

>pik update
・・・・・
Successfully installed pik-0.2.8
1 gem installed
Installing ri documentation for pik-0.2.8...
Updating class cache with 0 classes...
Installing RDoc documentation for pik-0.2.8...
Could not find main page README.rdoc
Thank you for using pik.
・・・・・
C:\Documents and Settings\takashi>pik ls -r -V
pik 0.2.8
---
DevKit:
3.4.5r3: http://rubyforge.org/frs/download.php/66888/devkit-3.4.5r3-20091110.7z
IronRuby:
0.3.0: http://rubyforge.org/frs/download.php/53552/ironruby-0.3.0.zip
0.5.0: http://rubyforge.org/frs/download.php/57126/ironruby-0.5.0.zip
0.6.0: http://rubyforge.org/frs/download.php/59717/ironruby-0.6.0.zip
0.9.0: http://rubyforge.org/frs/download.php/61382/ironruby-0.9.0.zip
0.9.1: http://rubyforge.org/frs/download.php/64504/ironruby-0.9.1.zip
0.9.2: http://rubyforge.org/frs/download.php/66606/ironruby-0.9.2.zip
"1.0": http://rubyforge.org/frs/download.php/70179/ironruby-1.0.zip
1.0-rc1: http://rubyforge.org/frs/download.php/67955/ironruby-1.0-rc1.zip
1.0-rc2: http://rubyforge.org/frs/download.php/69180/ironruby-1.0-rc2.zip
1.0.0rc: http://rubyforge.org/frs/download.php/69853/ironruby-1.0.0rc.zip
1.0rc3: http://rubyforge.org/frs/download.php/69665/ironruby-1.0rc3.zip
1.0v4: http://rubyforge.org/frs/download.php/70181/ironruby-1.0v4.zip
JRuby:
1.4.1: http://jruby.org.s3.amazonaws.com/downloads/1.4.1/jruby-bin-1.4.1.zip
1.5.1: http://jruby.org.s3.amazonaws.com/downloads/1.5.1/jruby-bin-1.5.1.zip
Ruby:
1.8.6-p398-2: http://rubyforge.org/frs/download.php/71102/ruby-1.8.6-p398-i386-mingw32-2.7z
1.8.7-p249-1: http://rubyforge.org/frs/download.php/71081/ruby-1.8.7-p249-i386-mingw32-1.7z
1.8.7-p299: http://rubyforge.org/frs/download.php/71493/ruby-1.8.7-p299-i386-mingw32.7z
1.9.1-p378-1: http://rubyforge.org/frs/download.php/71082/ruby-1.9.1-p378-i386-mingw32-1.7z
1.9.1-p429: http://rubyforge.org/frs/download.php/71496/ruby-1.9.1-p429-i386-mingw32.7z
1.9.2-rc1: http://rubyforge.org/frs/download.php/71498/ruby-1.9.2-rc1-i386-mingw32.7z
1.9.2dev-preview3-1: http://rubyforge.org/frs/download.php/71175/ruby-1.9.2dev-preview3-i386-mingw32-1.7z

2010年8月3日火曜日

EditerからIronRubyの実行


SciTEの日本語設定(utf-8)
[Options][Open ruby.properties]
command.go.*.rb=ruby $(FileNameExt)を
command.go *.rb=ir -Ku $(FileNameExt)に変更
[View][Output] を表示する
対象のスクリプトを選択して、F5キーで実行

2010/08/04
Notepad++ プラグインNppExecでは、GUIが表示されなかった。



2010年8月1日日曜日

ruby1.9 + TK

Ruby191\lib\ruby\1.9.1にコピーする。
SpecTclをdownloadする
guibuider-win32-ix86-20070129.exeを実行する。ruby/tkを選択する。
r
bottonをキャンバス?に貼り付けて、ダブルクリックでPropertiesが開くので-textを漢字ボタンに変更した。


Save Asでbottontst名で保存した。
bottontst.ui
bottontst.rb
bottontst_ui.rbのfileができる。
C:\rubyapi\tk\buttontst>ruby -Ku buttontst.rb
C:/rubyapi/tk/buttontst/buttontst_ui.rb:10: warning: variable $KCODE is no longer effective; ignored



>ruby bottonst.rbで実行するには、

#bottontst.rb
# -*- coding: utf-8 -*-を追加

# -*- coding: utf-8 -*-
# buttontst.rb --
#
# UI generated by GUI Builder Build 146 on 2010-08-01 17:21:51 from:
# C:/rubyapi/tk/buttontst/buttontst.ui
# This file is auto-generated. Only the code within
# '# BEGIN USER CODE (global|class)'
# '# END USER CODE (global|class)'
# and code inside the callback defs will be round-tripped.
#

# Add script's directory to lib load path
$:.unshift File.dirname(__FILE__)
require 'buttontst_ui'
require 'tk'

# BEGIN USER CODE global

# END USER CODE global

class Buttontst <>

# BEGIN CALLBACK CODE
# ONLY EDIT CODE INSIDE THE def FUNCTIONS.

# _button_1_command --
#
# Callback to handle _button_1 widget option -command
def _button_1_command(*args)
#<= ここにbutton_1の処理を記載
end

# END CALLBACK CODE

# BEGIN USER CODE class
#<=ここにclass コードを記載
# END USER CODE class
end

# Standalone Code Initialization - DO NOT EDIT
#
if $0 == __FILE__
begin
userinit
rescue NameError
# Ignore userinit not being defined
end
root = Tk.root
root.title('buttontst')
dlg = Buttontst.new(root)

#root.protocol('WM_DELETE_WINDOW', lambda { exit })
begin
run
rescue NameError
# Ignore run not being defined
end
Tk.mainloop
end

#buttontst_ui.rb
読み取り専用のチェックをはずす。
# -*- coding: utf-8 -*-を追加
   $KCODE = 'U'をコメントアウトする。



# -*- coding: utf-8 -*-
# buttontst_ui.rb --
#
# UI generated by GUI Builder Build 146 on 2010-08-01 18:15:30 from:
# C:/rubyapi/tk/buttontst/buttontst.ui
# THIS IS AN AUTOGENERATED FILE AND SHOULD NOT BE EDITED.
# The associated callback file should be modified instead.
#

# Use UTF-8 encoding
#$KCODE = 'U'

require 'tk'

class Buttontst_ui
def initialize(root)
@root = root


# Widget Initialization
@_button_1 = TkButton.new(@root,
'text' => "漢字ボタン"
)

# widget commands

@_button_1.configure(
'command' => lambda { _button_1_command }
)


# Geometry Management
@_button_1.grid(
'in' => @root,
'column' => 1,
'row' => 1,
'columnspan' => 1,
'ipadx' => 0,
'ipady' => 0,
'padx' => 0,
'pady' => 0,
'rowspan' => 1,
'sticky' => ""
)


# Resize Behavior
TkGrid.rowconfigure(@root, 1, 'weight' => 0, 'minsize' => 40, 'pad' => 0)
TkGrid.rowconfigure(@root, 2, 'weight' => 0, 'minsize' => 40, 'pad' => 0)
TkGrid.columnconfigure(@root, 1, 'weight' => 0, 'minsize' => 40, 'pad' => 0)
TkGrid.columnconfigure(@root, 2, 'weight' => 0, 'minsize' => 40, 'pad' => 0)
end
end




2010年7月28日水曜日

IronRuby コマンドプロンプトで UTF-8を出力するには

[ruby-list:45331] Re: Windows コマンドプロンプトで UTF-8を出力するには
を参考にして。
# utf8ntest.rb
require 'iconv'
class StdoutHook
def write(str)
STDOUT.write Iconv.conv('shift-jis', 'utf-8', str.to_s)
end
$> = new
end
str = "utf8日本語"
p str
puts str
print str, "\r\n"
printf("utf8日本語は%d文字\r\n", str.split(//u).length)

C:\rubyapi\utf8ntest>ir -v
IronRuby 1.1.0.0 on .NET 4.0.30319.1

C:\rubyapi\utf8ntest>ir utf8ntest.rb
"utf8\346\227\245\346\234\254\350\252\236"
utf8日本語
utf8日本語
utf8日本語は7文字

-Kuのオプションを付けるとpでも表示される。
C:\rubyapi\utf8ntest>ir -Ku utf8ntest.rb
"utf8日本語"
utf8日本語
utf8日本語
utf8日本語は7文字

printfの行を修正して、エラーを出すと
C:\rubyapi\utf8ntest>ir utf8ntest.rb
utf8ntest.rb:12: Invalid character 'a' in expression
printf(utf8a?\a?¬ea?a? ̄%da??a-?\r\n", str.split(//u).length)
^
C:\rubyapi\utf8ntest>ir -Ku utf8ntest.rb
utf8ntest.rb:12: syntax error, unexpected `\'
printf(utf8日本語は%d文字\r\n", str.split(//u).length)


2010年7月25日日曜日

ruby1.9.1 ビルドしたときのメモ

参考にしたところ
Windowsで使うRubyを自分でビルドする方法
Visual C++2008でコンバイルするRuby1.9.1-p129
Ruby 1.9.1-p0 : VC++ 2008 Express Editionでビルド

準備
(i) Visual C++ 2008 Express Edition をインストールする。
Visual Studio Express Editons
Visual C++ 2008 webインストール(ダウンロード)
はじめての方のためのインストール方法紹介を参考に

(ii) gnuwin32 の bison と sed をインストールする。
Bison for Window
Requirementsのsetup programから bison-2.4.1-setup.exeをDLしてインストール
インストール先はC:\GnuWin32
Sed for Windows
Requirementsのsetup programからsed-4.2-1-setup.exeをDLしてインストール
インストール先はC:\GnuWin32

C:\GnuWin32\binのpathを通す

BisonをC:\Program Files\GnuWin32\bin\bison.exeにインストールしたらnmakeでエラーとなった
C:\src\ruby-1.9.1-p376\win32>nmake
・
bison -d -o y.tab.c ./../parse.y
m4: cannot open `Files\GnuWin32/share/bison': No such file or directory
m4: cannot open `C:\Program': No such file or directory
m4: cannot open `Files\GnuWin32/share/bison/m4sugar/m4sugar.m4': No such file or directory
http://kmaebashi.com/bbs/list.php?boardid=kmaebashibbs&from=1435&range=1を参考に修正

ruby-1.9.1-p378.zipをC:\src\下にソースを展開

C:\Program Files\Microsoft Visual Studio 9.0\VC>set path=C:\Ruby\Ruby-186-p398-mingw32\bin;%path%
C:\Program Files\Microsoft Visual Studio 9.0\VC>ruby -v
ruby 1.8.6 (2010-02-04 patchlevel 398) [i386-mingw32]
C:\Program Files\Microsoft Visual Studio 9.0\VC>set path=%path%;C:\Ruby\Ruby-186-p398-mingw32\bin
C:\Program Files\Microsoft Visual Studio 9.0\VC>vcvars32.bat
C:\Program Files\Microsoft Visual Studio 9.0\VC>cd c:\src\ruby-1.9.1-p378\win32
C:\src\ruby-1.9.1-p378\win32>configure.bat --prefix=C:\Ruby\ruby-1.9.1-p378-mswin32-90
C:\src\ruby-1.9.1-p378\win32>nmake
C:\src\ruby-1.9.1-p378\win32>nmake /n install
C:\src\ruby-1.9.1-p378\win32>nmake install

C:\src\ruby-1.9.1-p378\win32>c:\ruby\ruby-1.9.1-p378-mswin32-90\bin\ruby -v
ruby 1.9.1p378 (2010-01-10 revision 26273) [i386-mswin32_90]


(iii) zlibをインストール
http://www.zlib.net/ からzlib123をDLしてc:\src\下に展開

vcのコンソールから
Setting environment for using Microsoft Visual Studio 2008 x86 tools.

C:\Program Files\Microsoft Visual Studio 9.0\VC>path=C:\Ruby\Ruby-186-p398-mingw32\bin;%path%
C:\Program Files\Microsoft Visual Studio 9.0\VC>vcvars32.bat

C:\Program Files\Microsoft Visual Studio 9.0\VC>cd c:\src\zlib123
C:\src\zlib123>nmake -f win32\Makefile.msc

C:\src\zlib123>mt -manifest zlib1.dll.manifest -outputresource:zlib1.dll;2
C:\src\zlib123>copy zlib1.dll c:\ruby\ruby-1.9.1-p378-mswin32-90\bin

C:\src\zlib123>cd cd c:\src\ruby-1.9.1-p378\ext\zlib

C:\src\ruby-1.9.1-p378\ext\zlib>c:\ruby\ruby-1.9.1-p378-mswin32-90\bin\ruby.exe extconf.rb --with-zlib-include=c:\src\zlib123 --with-zlib-lib=c:\src\zlib123
checking for deflateReset() in z.lib... no
checking for deflateReset() in libz.lib... no
checking for deflateReset() in zlib1.lib... no
checking for deflateReset() in zlib.lib... yes
checking for zlib.h... yes
checking for kind of operating system... Win32
creating Makefile

C:\src\ruby-1.9.1-p378\ext\zlib>nmake

C:\src\ruby-1.9.1-p378\ext\zlib>nmake install

Microsoft(R) Program Maintenance Utility Version 9.00.30729.01
Copyright (C) Microsoft Corporation. All rights reserved.

install -c -p -m 0755 zlib.so c:\ruby\ruby-1.9.1-p378-mswin32-90\lib\ruby\site_ruby\1.9.1\i386-msvcr90

C:\src\ruby-1.9.1-p378\ext\zlib>

コマンドプロンプトから
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\Administrator>path=c:\ruby\ruby-1.9.1-p378-mswin32-90\bin;%path%
C:\Documents and Settings\Administrator>ruby -v
ruby 1.9.1p378 (2010-01-10 revision 26273) [i386-mswin32_90]
C:\Documents and Settings\Administrator>gem -v
1.3.1

C:\Documents and Settings\Administrator>gem update --system
Updating RubyGems
Updating rubygems-update
Successfully installed rubygems-update-1.3.6
省略
RubyGems installed the following executables:
c:/Ruby/ruby-1.9.1-p378-mswin32-90/bin/gem


C:\Documents and Settings\Administrator>gem -v
1.3.6