⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dictionary.sb

📁 gtk_server的源代码
💻 SB
字号:
#!/usr/bin/scribaREM ************************************************************************REMREM DICT client to lookup wordsREM Using the HTML widgets of the Scriptbasic wrapperREMREM Expand the GTK namespace if you feel necessary!REM Feb. 10, 2006 - PvE.REMREM ************************************************************************REM Import GTK definition firstIMPORT gtk.basGLOBAL CONST nl = "\n"GLOBAL CONST title = "Thesaurus!"REM Create main windowmainwin = GTK::window(title, 500, 450)REM Create droplist partframe1 = GTK::frame(" Servers ", 255, 65)GTK::attach(frame1, mainwin, 10, 10)servers[0] = "dict.org"servers[1] = "dict.aioe.org"servers[2] = "dict.tugraz.at"servers[3] = "mova.org"servers[4] = "dict.tu-chemnitz.de"servers[5] = "test.dict.org"servers[6] = "dict.trit.org"servers[7] = "dict.die.net"servers[8] = "www.lojban.org"servers[9] = "dict.arabeyes.org"servers[10] = "muktaka.dyndns.org"servers[11] = "dict.saugus.net"servers[12] = "dictionary.bishopston.net"servers[13] = "la-sorciere.de"servers[14] = "es.dict.org"servers[15] = "lividict.org"servers[16] = "mali.geekcorps.org"servers[17] = "dione.zcu.cz"servers[18] = "dict.kurtwerks.com"servers[19] = "madison.onespeeddave.com"drop = GTK::droplist(servers, 165, 35)GTK::attach(drop, mainwin, 20, 30)fetch = GTK::button("Fetch", 60, 35)GTK::attach(fetch, mainwin, 195, 30)REM Create control panelframe2 = GTK::frame(" Control ", 210, 65)GTK::attach(frame2, mainwin, 275, 10)about = GTK::button("About", 60, 35)GTK::attach(about, mainwin, 285, 30)clear = GTK::button("Clear", 60, 35)GTK::attach(clear, mainwin, 350, 30)exbut = GTK::button("Exit", 60, 35)GTK::attach(exbut, mainwin, 415, 30)REM Create dictionary panelframe3 = GTK::frame(" Dictionaries ", 480, 125)GTK::attach(frame3, mainwin, 10, 85)dat[0] = ""list = GTK::list(dat, 460, 90)GTK::attach(list, mainwin, 20, 110)GTK::bg_color(list, 49152, 49152, 49152)REM Create text partframe4 = GTK::frame(" Translation ", 480, 190)GTK::attach(frame4, mainwin, 10, 220)text = GTK::text(460, 155)GTK::attach(text, mainwin, 20, 245)GTK::disable(text)GTK::bg_color(text, 49152, 49152, 49152)REM Create entry and lookup buttonentry = GTK::entry(360, 25)GTK::attach(entry, mainwin, 10, 420)utf8 = GTK::check("UTF-8", 60, 30)GTK::attach(utf8, mainwin, 430, 415)dflt = GTK::check("All", 40, 30)GTK::attach(dflt, mainwin, 380, 415)REM Create about windowaboutwin = GTK::window("About", 300, 120)GTK::hide(aboutwin)label1 = GTK::label("Demo program with the GTK module.", 280, 20)GTK::attach(label1, aboutwin, 10, 5)GTK::fg_color(label1, 32768, 0, 0)label2 = GTK::label("Using " & GTK::version() & " with Scriptbasic.", 280, 20)GTK::attach(label2, aboutwin, 10, 25)GTK::fg_color(label2, 0, 0, 32768)label3 = GTK::label("(C) Peter van Eerten - February 6, 2006", 280, 20)GTK::attach(label3, aboutwin, 10, 45)GTK::fg_color(label3, 0, 32768, 0)okbut = GTK::button("OK", 60, 35)GTK::attach(okbut, aboutwin, 120, 80)REM MainloopREPEAT	REM Put focus to entry	GTK::focus(entry)	REM Wait for event	action = GTK::event()	REM Get all dictionaries of server	IF action = fetch THEN CALL Get_Dicts	REM Get meaning of word	IF action = entry THEN CALL Lookup_Word	REM Clear all widgets	IF action = clear THEN CALL Clear_All	REM Show about window	IF action = about THEN GTK::show(aboutwin)	REM Hide about window	IF action = okbut OR action = aboutwin THEN GTK::hide(aboutwin)UNTIL action = mainwin OR action = exbutENDREM ************************************************************************SUB Get_DictsLOCAL dat$, total, countON ERROR GOTO G_NetErrorOPEN GTK::get_text(drop) & ":2628" FOR socket AS 1PRINT#1,"SHOW DB\n"LINE INPUT#1, dat$LINE INPUT#1, dat$count = 0WHILE LEFT(dat$, 1) <> "."	LINE INPUT#1, dat$	dat$ = REPLACE(dat$, CHR$(34), CHR$(92) & CHR$(34))	IF LEFT$(dat$, 1) <> "." THEN total[count] = TRIM(dat$)	count+=1WENDPRINT#1,"QUIT\n"CLOSE 1GTK::fg_color(list, 0, 0, 65535)GTK::set_text(list, total)EXIT SUBG_NetError:	dat$[0] = "Server not available!"	GTK::fg_color(list, 65535, 0, 0)	GTK::set_text(list, dat$)END SUBREM ************************************************************************SUB Lookup_WordLOCAL dict$, dat$, total$, info$GTK::set_text(mainwin, title & " - \\\"" & GTK::get_text(entry) & "\\\"")GTK::fg_color(text, 0, 32768, 0)GTK::set_text(text, "Fetching....")GTK::async()ON ERROR GOTO L_NetErrordict$ = LEFT(GTK::get_text(list), INSTR(GTK::get_text(list), " "))OPEN GTK::get_text(drop) & ":2628" FOR socket AS 1IF GTK::get_value(dflt) THEN	PRINT#1,"DEFINE * " & GTK::get_text(entry) & "\n"ELSE	PRINT#1,"DEFINE " & dict$ & " " & GTK::get_text(entry) & "\n"END IFREPEAT	LINE INPUT#1, dat$	dat$ = REPLACE(dat$, CHR$(34), CHR$(92) & CHR$(34))	IF LEFT(dat$, 3) = "151" THEN		total$ &= "------------------------------\n"		total$ &= RIGHT(dat$, LEN(dat$) - LEN(GTK::get_text(entry)) - 9)		total$ &= "------------------------------\n"		REPEAT			LINE INPUT#1, info$			info$ = REPLACE(info$, CHR$(34), CHR$(92) & CHR$(34))			IF LEFT(info$, 1) <> "." THEN total$ &= TRIM(info$) & nl		UNTIL LEFT(info$, 1) = "."		total$ &= "\n"	END IFUNTIL LEFT(dat$, 3) = "250" OR VAL(LEFT(dat$, 3)) > 499PRINT#1,"QUIT\n"CLOSE 1IF LEFT(dat$, 3) = "552" THEN	total$ = "No match found."	GTK::fg_color(text, 65535, 0, 0)ELSE IF LEFT(dat$, 3) = "501" THEN	total$ = "Select a dictionary first!"	GTK::fg_color(text, 65535, 0, 0)ELSE IF LEFT(dat$, 3) = "550" THEN	total$ = "Invalid database!"	GTK::fg_color(text, 65535, 0, 0)ELSE	GTK::fg_color(text, 0, 0, 49152)END IFIF GTK::get_value(utf8) THEN	GTK::set_text(text, GTK::UTF8(total$))ELSE	GTK::set_text(text, total$)END IFGTK::set_value(text, 0)EXIT SUBL_NetError:	dat$[0] = "Could not lookup word!"	GTK::fg_color(list, 65535, 0, 0)	GTK::set_text(list, dat$)END SUBREM ************************************************************************SUB Clear_AllLOCAL ar$ar$[0] = ""GTK::set_text(list, ar$)GTK::set_text(text, "")END SUBREM ************************************************************************

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -