A Simple X Image Viewer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011121314151617181920212223242526272829303132333435
  1. #!/usr/bin/awk -f
  2. function printchars() {
  3. while (n > 0) {
  4. x = n / 16 >= 1 ? 16 : n;
  5. printf("0x%x%x,%s", x - 1, ref[c] - 1, ++i % 12 == 0 ? "\n" : " ");
  6. n -= x;
  7. }
  8. }
  9. /^$/ {
  10. printchars();
  11. printf("\n\n");
  12. c = "";
  13. i = 0;
  14. }
  15. /./ {
  16. if (!ref[$0]) {
  17. col[cnt++] = $0;
  18. ref[$0] = cnt;
  19. }
  20. if ($0 != c) {
  21. if (c != "")
  22. printchars();
  23. c = $0;
  24. n = 0;
  25. }
  26. n++;
  27. }
  28. END {
  29. for (i = 0; i < cnt; i++)
  30. printf("%s,%s", col[i], ++j % 4 == 0 || i + 1 == cnt ? "\n" : " ");
  31. }