PageRenderTime 51ms CodeModel.GetById 31ms app.highlight 17ms RepoModel.GetById 1ms app.codeStats 0ms

/winsamp.d

http://github.com/wilkie/djehuty
D | 283 lines | 218 code | 51 blank | 14 comment | 8 complexity | ebd99cbccb66b0c178dd67899f62b65e MD5 | raw file
  1import djehuty;
  2
  3import data.list;
  4import gui.application;
  5import gui.window;
  6import gui.button;
  7import gui.widget;
  8import gui.listbox;
  9
 10import hashes.digest;
 11
 12import resource.menu;
 13
 14import graphics.graphics;
 15
 16import resource.image;
 17import resource.sound;
 18
 19import cui.application;
 20import cui.window;
 21import cui.label;
 22import cui.textfield;
 23import cui.tabbox;
 24import cui.container;
 25
 26import synch.timer;
 27import synch.thread;
 28import synch.atomic;
 29
 30import networking.irc;
 31
 32import io.console;
 33
 34import hashes.md5;
 35
 36import spec.test;
 37
 38import parsing.options;
 39
 40import io.file;
 41
 42import math.vector;
 43
 44import core.date;
 45
 46import cui.textfield;
 47import core.application;
 48
 49import cui.textbox;
 50import cui.codebox;
 51
 52import cui.dialog;
 53import cui.filebox;
 54import cui.listbox;
 55
 56import math.fixed;
 57import math.currency;
 58import math.integer;
 59import parsing.d.parser;
 60
 61import networking.ftp;
 62
 63private template _switch_string(T) {
 64	int _switch_string(T[][] table, T[] compare) {
 65		if (table.length == 0) {
 66			return -1;
 67		}
 68
 69		TypeInfo ti = typeid(T[]);
 70		// Binary search the table
 71		size_t min = 0;
 72		size_t max = table.length;
 73
 74		// Current comparing position
 75		size_t cur;
 76
 77		// Temp for compare value
 78		int cmp;
 79
 80		while(max > min) {
 81			cur = (max + min) / 2;
 82			cmp = ti.compare(&table[cur], &compare);
 83
 84			if (cmp == 0) {
 85				return cur;
 86			}
 87			else if (cmp > 0) {
 88				max = cur;
 89			}		
 90			else {
 91				min = cur + 1;
 92			}
 93		}
 94
 95		return -1;
 96	}
 97}
 98
 99
100import spec.specification;
101
102import data.queue2;
103
104class MyConsoleApp : Application {
105	static this() { new MyConsoleApp(); }
106
107	override void onApplicationStart() {
108		q = new Queue2!(string);
109		Thread t = Thread.current;
110
111		ulong a, b, c;
112		a = 4;
113		b = 0b10011101_10110011_11100011_11011010;
114		c = 5;
115		Console.putln("{1}, {0}, {1}, {0:X}, {} {} {X8} {00.0000}".format(12, 11, 13, 3.4));
116		Console.putln(a,b,c);
117		Console.putln(Atomic.compareExchange(a,b,c));
118		Console.putln(a,b,c);
119
120		float d,e,f;
121		d = 1.0;
122		e = 1.1;
123		f = 2.234;
124		Console.putln(d,e,f);
125		Console.putln(Atomic.compareExchange(d,e,f));
126		Console.putln(d,e,f);
127
128		void* A=null;
129		void* B=cast(void*)0xfe;
130		void* C=cast(void*)0xff;
131
132		Console.putln(A,B,C);
133		Console.putln(Atomic.compareExchange(A,B,C));
134		Console.putln(A,B,C);
135
136		short g,h,i;
137		g = 3;
138		h = 4;
139		i = 4;		
140		Console.putln(g,h,i);
141		Console.putln(Atomic.compareExchange(g,h,i));
142		Console.putln(g,h,i);
143
144		Console.putln([1,2,3,4].rotate(2));
145		Console.putln("hello"c.dup.reverse);
146		/*Console.putln("he\u0364llo"c.dup.reverse);
147		Console.putln("hlle\u0364o"c.dup.reverse);
148		Console.putln("he\u0364po"c.dup.reverse);
149		Console.putln("he\u0364llo"w.dup.reverse);
150		Console.putln("he\u0364llo"d.dup.reverse);
151		Console.putln("he\u0364llo"d.dup.reverse());*/
152		Console.putln([1,2,3,4,5,6,7,8].dup.reverse());
153		Console.putln(new Fixed(3.5));
154		//Atomic.exchange(a,6);
155		Console.putln(a,b,c);
156		Console.putln("{c}".format(1500.42));
157		Locale.id = LocaleId.French_FR;
158		Console.putln("{c}".format(1500.42));
159		Console.putln(new Currency(150042,2));
160		t = new Thread(&foo);
161		t.start();
162
163		t = new Thread(&foo);
164		t.start();
165		t = new Thread(&foo);
166		t.start();
167		t = new Thread(&foo);
168		t.start();
169		t = new Thread(&foo);
170		t.start();
171		t = new Thread(&foo);
172		t.start();
173		t = new Thread(&foo);
174		t.start();
175		t = new Thread(&foo);
176		t.start();
177		t = new Thread(&foo);
178		t.start();
179		Timer tmr = new Timer(250);
180		push(tmr);
181		tmr.start();
182		//while(freak < 9) {
183		//}
184		Console.forecolor = Color.White;
185		Console.putln("White");
186		Console.forecolor = Color.Red;
187		Console.putln("Red");
188		Console.forecolor = Color.Green;
189		Console.putln("Green");
190		Console.forecolor = Color.Blue;
191		Console.putln("Blue");
192		Console.forecolor = Color.Yellow;
193		Console.putln("Yellow");
194		Console.forecolor = Color.Magenta;
195		Console.putln("Magenta");
196		Console.forecolor = Color.Cyan;
197		Console.putln("Cyan");
198		Console.forecolor = Color.Gray;
199		Console.putln("Gray");
200		Console.forecolor = Color.DarkGray;
201		Console.putln("DarkGray");
202		Console.forecolor = Color.DarkRed;
203		Console.putln("DarkRed");
204		Console.forecolor = Color.DarkGreen;
205		Console.putln("DarkGreen");
206		Console.forecolor = Color.DarkBlue;
207		Console.putln("DarkBlue");
208		Console.forecolor = Color.DarkYellow;
209		Console.putln("DarkYellow");
210		Console.forecolor = Color.DarkMagenta;
211		Console.putln("DarkMagenta");
212		Console.forecolor = Color.DarkCyan;
213		Console.putln("DarkCyan");
214		Console.forecolor = Color.Black;
215		Console.putln("Black");
216		Console.forecolor = Color.Gray;
217		ulong foo = 45;
218		Console.putln(foo);
219		Atomic.add(foo, 45);
220		Console.putln(foo);
221		Console.putln(q);
222		
223		Console.putln([1,2,3,4].rotate(-1));
224
225		foreach_reverse(dchar d; "he\u0364llo"c) {
226			Console.putln(d);
227		}
228
229		Console.putln([3,2,1].sort);	
230		Console.putln([[1,2],[2,3],[3],[1],[0]].sort);
231
232		typedef int oneint = 3;
233		oneint fb;
234		oneint[] oneints = new oneint[10];
235		//Console.putln(oneints[0]);
236		//Console.putln(fb);
237
238		dstring[] fuzz = [
239			"abc",
240			"zzt"
241			"hello",
242		];
243
244		string foobe = "hello";
245
246		switch(foobe) {
247			case "abc":
248			case "zzt":
249				break;
250			case "hello":
251				Console.putln("yay");
252				break;
253			default:
254				break;
255		}
256
257		Console.putln(_switch_string(fuzz, "hello"d));
258
259		for(;;){}
260	}
261
262	override bool onSignal(Dispatcher dsp, uint signal) {
263		Console.putln("fire");
264		return true;
265	}
266
267	void foo(bool bar) {
268		Atomic.increment(fudge);
269		while(fudge < 9) {
270		}
271		q.add("foobara");
272		q.add("foobarb");
273		q.remove();
274		q.add("foobarc");
275		q.add("foobard");
276		q.remove();
277		Atomic.increment(freak);
278	}
279
280	ulong fudge;
281	ulong freak;
282	Queue2!(string) q;
283}