Mercurial > pidgin.yaz
comparison console/libgnt/gntmain.c @ 14029:d63f59ee6c98
[gaim-migrate @ 16631]
Press Alt+d to get an HTML-dump of the contents of the screen. The dump
goes in "dump.html" in pwd.
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sat, 05 Aug 2006 02:19:19 +0000 |
parents | 7573bd40a190 |
children | 143474e2b1cb |
comparison
equal
deleted
inserted
replaced
14028:4c939ea15004 | 14029:d63f59ee6c98 |
---|---|
306 if (focus_list == list) | 306 if (focus_list == list) |
307 focus_list = g_list_find(all, widget); | 307 focus_list = g_list_find(all, widget); |
308 draw_taskbar(); | 308 draw_taskbar(); |
309 } | 309 } |
310 | 310 |
311 static void | |
312 dump_screen() | |
313 { | |
314 int x, y; | |
315 chtype old = 0, now = 0; | |
316 FILE *file = fopen("dump.html", "w"); | |
317 | |
318 fprintf(file, "<pre>"); | |
319 for (y = 0; y < getmaxy(stdscr); y++) | |
320 { | |
321 for (x = 0; x < getmaxx(stdscr); x++) | |
322 { | |
323 char ch; | |
324 now = mvwinch(newscr, y, x); | |
325 ch = now & A_CHARTEXT; | |
326 now ^= ch; | |
327 | |
328 #define CHECK(attr, start, end) \ | |
329 do \ | |
330 { \ | |
331 if (now & attr) \ | |
332 { \ | |
333 if (!(old & attr)) \ | |
334 fprintf(file, start); \ | |
335 } \ | |
336 else if (old & attr) \ | |
337 { \ | |
338 fprintf(file, end); \ | |
339 } \ | |
340 } while (0) | |
341 | |
342 CHECK(A_BOLD, "<b>", "</b>"); | |
343 CHECK(A_UNDERLINE, "<u>", "</u>"); | |
344 CHECK(A_BLINK, "<blink>", "</blink>"); | |
345 | |
346 if ((now & A_COLOR) != (old & A_COLOR)) | |
347 { | |
348 int ret; | |
349 short fgp, bgp, r, g, b; | |
350 struct | |
351 { | |
352 int r, g, b; | |
353 } fg, bg; | |
354 | |
355 ret = pair_content(PAIR_NUMBER(now & A_COLOR), &fgp, &bgp); | |
356 ret = color_content(fgp, &r, &g, &b); | |
357 fg.r = r; fg.b = b; fg.g = g; | |
358 ret = color_content(bgp, &r, &g, &b); | |
359 bg.r = r; bg.b = b; bg.g = g; | |
360 #define ADJUST(x) (x = x * 255 / 1000) | |
361 ADJUST(fg.r); | |
362 ADJUST(fg.g); | |
363 ADJUST(fg.b); | |
364 ADJUST(bg.r); | |
365 ADJUST(bg.b); | |
366 ADJUST(bg.g); | |
367 | |
368 if (x) fprintf(file, "</span>"); | |
369 fprintf(file, "<span style=\"background:#%02x%02x%02x;color:#%02x%02x%02x\">", | |
370 bg.r, bg.g, bg.b, fg.r, fg.g, fg.b); | |
371 } | |
372 if (now & A_ALTCHARSET) | |
373 { | |
374 switch (ch) | |
375 { | |
376 case 'q': | |
377 ch = '-'; break; | |
378 case 't': | |
379 case 'u': | |
380 case 'x': | |
381 ch = '|'; break; | |
382 case 'v': | |
383 case 'w': | |
384 case 'l': | |
385 case 'm': | |
386 case 'k': | |
387 case 'j': | |
388 case 'n': | |
389 ch = '+'; break; | |
390 default: | |
391 ch = ' '; break; | |
392 } | |
393 } | |
394 fprintf(file, "%c", ch); | |
395 old = now; | |
396 } | |
397 fprintf(file, "</span>\n"); | |
398 old = 0; | |
399 } | |
400 fprintf(file, "</pre>"); | |
401 fclose(file); | |
402 } | |
403 | |
311 static gboolean | 404 static gboolean |
312 io_invoke(GIOChannel *source, GIOCondition cond, gpointer null) | 405 io_invoke(GIOChannel *source, GIOCondition cond, gpointer null) |
313 { | 406 { |
314 char buffer[256]; | 407 char buffer[256]; |
315 gboolean ret = FALSE; | 408 gboolean ret = FALSE; |
328 printf("EOF\n"); | 421 printf("EOF\n"); |
329 exit(1); | 422 exit(1); |
330 } | 423 } |
331 | 424 |
332 buffer[rd] = 0; | 425 buffer[rd] = 0; |
426 | |
427 if (buffer[0] == 27 && buffer[1] == 'd' && buffer[2] == 0) | |
428 { | |
429 /* This dumps the screen contents in an html file */ | |
430 dump_screen(); | |
431 } | |
333 | 432 |
334 if (mode == GNT_KP_MODE_NORMAL) | 433 if (mode == GNT_KP_MODE_NORMAL) |
335 { | 434 { |
336 if (focus_list) | 435 if (focus_list) |
337 { | 436 { |
565 nodes = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, free_node); | 664 nodes = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, free_node); |
566 | 665 |
567 wbkgdset(stdscr, '\0' | COLOR_PAIR(GNT_COLOR_NORMAL)); | 666 wbkgdset(stdscr, '\0' | COLOR_PAIR(GNT_COLOR_NORMAL)); |
568 noecho(); | 667 noecho(); |
569 refresh(); | 668 refresh(); |
570 #if MAYBE_SOMEDAY | 669 #if 0 |
571 mousemask(ALL_MOUSE_EVENTS | REPORT_MOUSE_POSITION, NULL); | 670 mousemask(NCURSES_BUTTON_PRESSED | NCURSES_BUTTON_RELEASED | REPORT_MOUSE_POSITION, NULL); |
572 #endif | 671 #endif |
573 wbkgdset(stdscr, '\0' | COLOR_PAIR(GNT_COLOR_NORMAL)); | 672 wbkgdset(stdscr, '\0' | COLOR_PAIR(GNT_COLOR_NORMAL)); |
574 werase(stdscr); | 673 werase(stdscr); |
575 wrefresh(stdscr); | 674 wrefresh(stdscr); |
576 | 675 |