updated iup.nim; made tests green

This commit is contained in:
Araq 2014-08-31 22:55:51 +02:00
commit 41c7cde61f
9 changed files with 1055 additions and 1058 deletions

View file

@ -1,37 +1,37 @@
# Example IUP program
# IupTabs: Creates a IupTabs control.
# iupTabs: Creates a iupTabs control.
import iup
discard iup.Open(nil, nil)
discard iup.open(nil, nil)
var vbox1 = Iup.Vbox(Iup.Label("Inside Tab A"), Iup.Button("Button A", ""), nil)
var vbox2 = Iup.Vbox(Iup.Label("Inside Tab B"), Iup.Button("Button B", ""), nil)
var vbox1 = iup.vbox(iup.label("Inside Tab A"), iup.button("Button A", ""), nil)
var vbox2 = iup.vbox(iup.label("Inside Tab B"), iup.button("Button B", ""), nil)
Iup.SetAttribute(vbox1, "TABTITLE", "Tab A")
Iup.SetAttribute(vbox2, "TABTITLE", "Tab B")
iup.setAttribute(vbox1, "TABTITLE", "Tab A")
iup.setAttribute(vbox2, "TABTITLE", "Tab B")
var tabs1 = Iup.Tabs(vbox1, vbox2, nil)
var tabs1 = iup.tabs(vbox1, vbox2, nil)
vbox1 = Iup.Vbox(Iup.Label("Inside Tab C"), Iup.Button("Button C", ""), nil)
vbox2 = Iup.Vbox(Iup.Label("Inside Tab D"), Iup.Button("Button D", ""), nil)
vbox1 = iup.vbox(iup.label("Inside Tab C"), iup.button("Button C", ""), nil)
vbox2 = iup.vbox(iup.label("Inside Tab D"), iup.button("Button D", ""), nil)
Iup.SetAttribute(vbox1, "TABTITLE", "Tab C")
Iup.SetAttribute(vbox2, "TABTITLE", "Tab D")
iup.setAttribute(vbox1, "TABTITLE", "Tab C")
iup.setAttribute(vbox2, "TABTITLE", "Tab D")
var tabs2 = Iup.Tabs(vbox1, vbox2, nil)
Iup.SetAttribute(tabs2, "TABTYPE", "LEFT")
var tabs2 = iup.tabs(vbox1, vbox2, nil)
iup.setAttribute(tabs2, "TABTYPE", "LEFT")
var box = Iup.Hbox(tabs1, tabs2, nil)
Iup.SetAttribute(box, "MARGIN", "10x10")
Iup.SetAttribute(box, "GAP", "10")
var box = iup.hbox(tabs1, tabs2, nil)
iup.setAttribute(box, "MARGIN", "10x10")
iup.setAttribute(box, "GAP", "10")
var dlg = Iup.Dialog(box)
Iup.SetAttribute(dlg, "TITLE", "IupTabs")
Iup.SetAttribute(dlg, "SIZE", "200x100")
var dlg = iup.dialog(box)
iup.setAttribute(dlg, "TITLE", "iupTabs")
iup.setAttribute(dlg, "SIZE", "200x100")
discard ShowXY(dlg, IUP_CENTER, IUP_CENTER)
discard MainLoop()
Close()
discard showXY(dlg, IUP_CENTER, IUP_CENTER)
discard mainLoop()
close()

View file

@ -9,21 +9,21 @@ var
event: TEvent
bgColor = colChocolate.int32
if init(INIT_VIDEO) != 0:
if Init(INIT_VIDEO) != 0:
quit "SDL failed to initialize!"
screen = SetVideoMode(640, 480, 16, SWSURFACE or ANYFORMAT)
if screen.isNil:
quit($sdl.getError())
quit($sdl.GetError())
greeting = IMG_load("tux.png")
if greeting.isNil:
echo "Failed to load tux.png"
else:
## convert the image to alpha and free the old one
var s = greeting.displayFormatAlpha()
var s = greeting.DisplayFormatAlpha()
swap(greeting, s)
s.freeSurface()
s.FreeSurface()
r.x = 0
r.y = 0
@ -31,7 +31,7 @@ r.y = 0
block game_loop:
while true:
while pollEvent(addr event) > 0:
while PollEvent(addr event) > 0:
case event.kind
of QUITEV:
break game_loop
@ -41,12 +41,12 @@ block game_loop:
else:
discard
discard fillRect(screen, nil, bgColor)
discard blitSurface(greeting, nil, screen, addr r)
discard flip(screen)
discard FillRect(screen, nil, bgColor)
discard BlitSurface(greeting, nil, screen, addr r)
discard Flip(screen)
greeting.freeSurface()
screen.freeSurface()
greeting.FreeSurface()
screen.FreeSurface()
sdl.Quit()
## fowl wuz here 10/2012

View file

@ -8,14 +8,14 @@ import os, streams, parsecsv, strutils, math
if paramCount() < 1:
quit("Usage: statcsv filename[.csv]")
var filename = addFileExt(ParamStr(1), "csv")
var filename = addFileExt(paramStr(1), "csv")
var s = newFileStream(filename, fmRead)
if s == nil: quit("cannot open the file " & filename)
var
x: TCsvParser
x: CsvParser
header: seq[string]
res: seq[TRunningStat]
res: seq[RunningStat]
open(x, s, filename, separator=';', skipInitialSpace = true)
while readRow(x):
if processedRows(x) == 1: