Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 
 

55 lignes
1.6 KiB

  1. /**
  2. * libcaca Java bindings for libcaca
  3. * Copyright (c) 2009 Adrien Grand <jpountz@dinauz.org>
  4. *
  5. * $Id$
  6. *
  7. * This library is free software. It comes without any warranty, to
  8. * the extent permitted by applicable law. You can redistribute it
  9. * and/or modify it under the terms of the Do What The Fuck You Want
  10. * To Public License, Version 2, as published by Sam Hocevar. See
  11. * http://sam.zoy.org/wtfpl/COPYING for more details.
  12. */
  13. import org.zoy.caca.Canvas;
  14. import org.zoy.caca.Color;
  15. import org.zoy.caca.Display;
  16. import org.zoy.caca.Event;
  17. import org.zoy.caca.TimeoutException;
  18. public class Driver {
  19. public static void main(String[] args) {
  20. Canvas cv = new Canvas(32, 16);
  21. Display dp = new Display(cv);
  22. cv.setColor(Color.Ansi.WHITE, Color.Ansi.BLACK);
  23. Display.Driver driver;
  24. int i, cur = 0;
  25. while(true) {
  26. cv.put(1, 0, "Available drivers");
  27. driver = dp.getDriver();
  28. Display.Driver[] list = Display.getDriverList();
  29. for (i = 0; i < list.length; i++) {
  30. if (driver.equals(list[i])) {
  31. cur = i;
  32. }
  33. cv.drawLine(0, 2*i+2, 9999, 2*i+2, ' ');
  34. cv.put(2, 2*i+2, (cur == i ? "* " : " ") + list[i].getCode() + " " + list[i].getDescription());
  35. }
  36. cv.put(1, 2*i + 2, "Switching driver in 5 seconds");
  37. dp.refresh();
  38. try {
  39. dp.getEvent(Event.Type.KEY_PRESS, 5000000);
  40. break;
  41. } catch(TimeoutException e) {
  42. // Let's continue
  43. }
  44. cur++;
  45. if (list[cur].getCode().equals("raw")) cur++;
  46. if (cur >= list.length) cur = 0;
  47. dp.setDriver(list[cur]);
  48. }
  49. }
  50. }