Author Topic: CODE Tags and Description bug reports/suggestion  (Read 2846 times)

0 Members and 1 Guest are viewing this topic.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
CODE Tags and Description bug reports/suggestion
« on: November 02, 2011, 05:34:16 pm »
Netham45, while the new code tags with line numbering are nice, for some reasons they look kinda weird with the new fonts. Also i noticed some display glitch causing numbers to not be aligned with the code. See the attachment below.

The misalignment of numbers doesn't seem to happen all the time, though. However when it does, it can be confusing which line is what.

Also the text is too big IMHO for code tags. Not only that but now that it doesn,t use a monospaced font anymore, it can make it harder to post code or read parts of it (especially TI-BASIC with strings or ASCII art).

Would it be possible to change the font and its size back to what it was prior the addition of numbering?

Thanks in advance.

Also, another thing about code tags: Would it be possible to check the CSS if it would be possible to change it for code tags so in Chrome they no longer end up being tiny when put in SPOILER tags? I think the CSS in the following topic (inside the js code) might help: http://ourl.ca/13513/254534

Besides that, there's a bug with Topic Descriptions: When editing the first post of the topic, the description is removed from the field.
« Last Edit: November 02, 2011, 05:37:49 pm by DJ_O »

Offline flyingfisch

  • I'm 1337 now!
  • Members
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1620
  • Rating: +94/-17
  • Testing, testing, 1...2...3...4...5...6...7...8..9
    • View Profile
    • Top Page Website Design
Re: CODE Tags suggestion
« Reply #1 on: November 02, 2011, 05:36:53 pm »
Seconded



Quote from: my dad
"welcome to the world of computers, where everything seems to be based on random number generators"



The Game V. 2.0

Offline Yeong

  • Not a bridge
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3739
  • Rating: +278/-12
  • Survivor of Apocalypse
    • View Profile
Re: CODE Tags suggestion
« Reply #2 on: November 02, 2011, 05:36:54 pm »
I definitely didn't see that watermark....
* Yeong lost
« Last Edit: November 02, 2011, 05:37:02 pm by yeongJIN_COOL »
Sig wipe!

Offline parserp

  • Hero Extraordinaire
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1455
  • Rating: +88/-7
  • The King Has Returned
    • View Profile
Re: CODE Tags and Description bug reports/suggestion
« Reply #3 on: November 02, 2011, 05:38:18 pm »
thirded
I lost the game too... :P

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: CODE Tags and Description bug reports/suggestion
« Reply #4 on: November 03, 2011, 11:35:41 pm »
Another suggestion: Can the line numbers be added in JavaScript? The reason I ask for this is because the way it is now, email notifications display code blocks like this:
Spoiler For Huge quote box:
Quote from: Email notification
Code: Select All | Copy To Clipboard
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212

AwesomeCode();
More awesome code!
Insane code!
Output(1,1,"Hello world!")
Output(2,1,"Hello world!")
Output(3,1,"Hello world!")
Output(4,1,"Hello world!")
/*
 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 *   - Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *
 *   - Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in the
 *     documentation and/or other materials provided with the distribution.
 *
 *   - Neither the name of Oracle nor the names of its
 *     contributors may be used to endorse or promote products derived
 *     from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

import java.nio.file.*;
import static java.nio.file.StandardCopyOption.*;
import java.nio.file.attribute.*;
import static java.nio.file.FileVisitResult.*;
import java.io.IOException;
import java.util.*;

/**
 * Sample code that copies files in a similar manner to the cp(1) program.
 */

public class Copy {

   /**
    * Returns {@code true} if okay to overwrite a  file ("cp -i")
    */
   static boolean okayToOverwrite(Path file) {
       String answer = System.console().readLine("overwrite %s (yes/no)? ", file);
       return (answer.equalsIgnoreCase("y") || answer.equalsIgnoreCase("yes"));
   }

   /**
    * Copy source file to target location. If {@code prompt} is true then
    * prompt user to overwrite target if it exists. The {@code preserve}
    * parameter determines if file attributes should be copied/preserved.
    */
   static void copyFile(Path source, Path target, boolean prompt, boolean preserve) {
       CopyOption[] options = (preserve) ?
           new CopyOption[] { COPY_ATTRIBUTES, REPLACE_EXISTING } :
           new CopyOption[] { REPLACE_EXISTING };
       if (!prompt || Files.notExists(target) || okayToOverwrite(target)) {
           try {
               Files.copy(source, target, options);
           } catch (IOException x) {
               System.err.format("Unable to copy: %s: %s%n", source, x);
           }
       }
   }

   /**
    * A {@code FileVisitor} that copies a file-tree ("cp -r")
    */
   static class TreeCopier implements FileVisitor<Path> {
       private final Path source;
       private final Path target;
       private final boolean prompt;
       private final boolean preserve;

       TreeCopier(Path source, Path target, boolean prompt, boolean preserve) {
           this.source = source;
           this.target = target;
           this.prompt = prompt;
           this.preserve = preserve;
       }

       @Override
       public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) {
           // before visiting entries in a directory we copy the directory
           // (okay if directory already exists).
           CopyOption[] options = (preserve) ?
               new CopyOption[] { COPY_ATTRIBUTES } : new CopyOption[0];

           Path newdir = target.resolve(source.relativize(dir));
           try {
               Files.copy(dir, newdir, options);
           } catch (FileAlreadyExistsException x) {
               // ignore
           } catch (IOException x) {
               System.err.format("Unable to create: %s: %s%n", newdir, x);
               return SKIP_SUBTREE;
           }
           return CONTINUE;
       }

       @Override
       public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
           copyFile(file, target.resolve(source.relativize(file)),
                    prompt, preserve);
           return CONTINUE;
       }

       @Override
       public FileVisitResult postVisitDirectory(Path dir, IOException exc) {
           // fix up modification time of directory when done
           if (exc == null && preserve) {
               Path newdir = target.resolve(source.relativize(dir));
               try {
                   FileTime time = Files.getLastModifiedTime(dir);
                   Files.setLastModifiedTime(newdir, time);
               } catch (IOException x) {
                   System.err.format("Unable to copy all attributes to: %s: %s%n", newdir, x);
               }
           }
           return CONTINUE;
       }

       @Override
       public FileVisitResult visitFileFailed(Path file, IOException exc) {
           if (exc instanceof FileSystemLoopException) {
               System.err.println("cycle detected: " + file);
           } else {
               System.err.format("Unable to copy: %s: %s%n", file, exc);
           }
           return CONTINUE;
       }
   }

   static void usage() {
       System.err.println("java Copy [-ip] source... target");
       System.err.println("java Copy -r [-ip] source-dir... target");
       System.exit(-1);
   }

   public static void main(String[] args) throws IOException {
       boolean recursive = false;
       boolean prompt = false;
       boolean preserve = false;

       // process options
       int argi = 0;
       while (argi < args.length) {
           String arg = args[argi];
           if (!arg.startsWith("-"))
               break;
           if (arg.length() < 2)
               usage();
           for (int i=1; i<arg.length(); i++) {
               char c = arg.charAt(i);
               switch (c) {
                   case 'r' : recursive = true; break;
                   case 'i' : prompt = true; break;
                   case 'p' : preserve = true; break;
                   default : usage();
               }
           }
           argi++;
       }

       // remaining arguments are the source files(s) and the target location
       int remaining = args.length - argi;
       if (remaining < 2)
           usage();
       Path[] source = new Path[remaining-1];
       int i=0;
       while (remaining > 1) {
           source[i++] = Paths.get(args[argi++]);
           remaining--;
       }
       Path target = Paths.get(args[argi]);

       // check if target is a directory
       boolean isDir = Files.isDirectory(target);

       // copy each source file/directory to target
       for (i=0; i<source.length; i++) {
           Path dest = (isDir) ? target.resolve(source.getFileName()) : target;

           if (recursive) {
               // follow links when copying files
               EnumSet<FileVisitOption> opts = EnumSet.of(FileVisitOption.FOLLOW_LINKS);
               TreeCopier tc = new TreeCopier(source, dest, prompt, preserve);
               Files.walkFileTree(source, opts, Integer.MAX_VALUE, tc);
           } else {
               // not recursive so source must not be a directory
               if (Files.isDirectory(source)) {
                   System.err.format("%s: is a directory%n", source);
                   continue;
               }
               copyFile(source, dest, prompt, preserve);
           }
       }
   }
}


clip = new ZeroClipboard.Client();clip.setHandCursor( true );clip.glue("a-2");clip.setText(StripHTML("AwesomeCode();
More awesome code!
Insane code!
Output(1,1,"Hello world!")
Output(2,1,"Hello world!")
Output(3,1,"Hello world!")
Output(4,1,"Hello world!")
/*
 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 *   - Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *
 *   - Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in the
 *     documentation and/or other materials provided with the distribution.
 *
 *   - Neither the name of Oracle nor the names of its
 *     contributors may be used to endorse or promote products derived
 *     from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

import java.nio.file.*;
import static java.nio.file.StandardCopyOption.*;
import java.nio.file.attribute.*;
import static java.nio.file.FileVisitResult.*;
import java.io.IOException;
import java.util.*;

/**
 * Sample code that copies files in a similar manner to the cp(1) program.
 */

public class Copy {

   /**
    * Returns {@code true} if okay to overwrite a  file ("cp -i")
    */
   static boolean okayToOverwrite(Path file) {
       String answer = System.console().readLine("overwrite %s (yes/no)? ", file);
       return (answer.equalsIgnoreCase("y") || answer.equalsIgnoreCase("yes"));
   }

   /**
    * Copy source file to target location. If {@code prompt} is true then
    * prompt user to overwrite target if it exists. The {@code preserve}
    * parameter determines if file attributes should be copied/preserved.
    */
   static void copyFile(Path source, Path target, boolean prompt, boolean preserve) {
       CopyOption[] options = (preserve) ?
           new CopyOption[] { COPY_ATTRIBUTES, REPLACE_EXISTING } :
           new CopyOption[] { REPLACE_EXISTING };
       if (!prompt || Files.notExists(target) || okayToOverwrite(target)) {
           try {
               Files.copy(source, target, options);
           } catch (IOException x) {
               System.err.format("Unable to copy: %s: %s%n", source, x);
           }
       }
   }

   /**
    * A {@code FileVisitor} that copies a file-tree ("cp -r")
    */
   static class TreeCopier implements FileVisitor<Path> {
       private final Path source;
       private final Path target;
       private final boolean prompt;
       private final boolean preserve;

       TreeCopier(Path source, Path target, boolean prompt, boolean preserve) {
           this.source = source;
           this.target = target;
           this.prompt = prompt;
           this.preserve = preserve;
       }

       @Override
       public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) {
           // before visiting entries in a directory we copy the directory
           // (okay if directory already exists).
           CopyOption[] options = (preserve) ?
               new CopyOption[] { COPY_ATTRIBUTES } : new CopyOption[0];

           Path newdir = target.resolve(source.relativize(dir));
           try {
               Files.copy(dir, newdir, options);
           } catch (FileAlreadyExistsException x) {
               // ignore
           } catch (IOException x) {
               System.err.format("Unable to create: %s: %s%n", newdir, x);
               return SKIP_SUBTREE;
           }
           return CONTINUE;
       }

       @Override
       public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
           copyFile(file, target.resolve(source.relativize(file)),
                    prompt, preserve);
           return CONTINUE;
       }

       @Override
       public FileVisitResult postVisitDirectory(Path dir, IOException exc) {
           // fix up modification time of directory when done
           if (exc == null && preserve) {
               Path newdir = target.resolve(source.relativize(dir));
               try {
                   FileTime time = Files.getLastModifiedTime(dir);
                   Files.setLastModifiedTime(newdir, time);
               } catch (IOException x) {
                   System.err.format("Unable to copy all attributes to: %s: %s%n", newdir, x);
               }
           }
           return CONTINUE;
       }

       @Override
       public FileVisitResult visitFileFailed(Path file, IOException exc) {
           if (exc instanceof FileSystemLoopException) {
               System.err.println("cycle detected: " + file);
           } else {
               System.err.format("Unable to copy: %s: %s%n", file, exc);
           }
           return CONTINUE;
       }
   }

   static void usage() {
       System.err.println("java Copy [-ip] source... target");
       System.err.println("java Copy -r [-ip] source-dir... target");
       System.exit(-1);
   }

   public static void main(String[] args) throws IOException {
       boolean recursive = false;
       boolean prompt = false;
       boolean preserve = false;

       // process options
       int argi = 0;
       while (argi < args.length) {
           String arg = args[argi];
           if (!arg.startsWith("-"))
               break;
           if (arg.length() < 2)
               usage();
           for (int i=1; i<arg.length(); i++) {
               char c = arg.charAt(i);
               switch (c) {
                   case 'r' : recursive = true; break;
                   case 'i' : prompt = true; break;
                   case 'p' : preserve = true; break;
                   default : usage();
               }
           }
           argi++;
       }

       // remaining arguments are the source files(s) and the target location
       int remaining = args.length - argi;
       if (remaining < 2)
           usage();
       Path[] source = new Path[remaining-1];
       int i=0;
       while (remaining > 1) {
           source[i++] = Paths.get(args[argi++]);
           remaining--;
       }
       Path target = Paths.get(args[argi]);

       // check if target is a directory
       boolean isDir = Files.isDirectory(target);

       // copy each source file/directory to target
       for (i=0; i<source.length; i++) {
           Path dest = (isDir) ? target.resolve(source.getFileName()) : target;

           if (recursive) {
               // follow links when copying files
               EnumSet<FileVisitOption> opts = EnumSet.of(FileVisitOption.FOLLOW_LINKS);
               TreeCopier tc = new TreeCopier(source, dest, prompt, preserve);
               Files.walkFileTree(source, opts, Integer.MAX_VALUE, tc);
           } else {
               // not recursive so source must not be a directory
               if (Files.isDirectory(source)) {
                   System.err.format("%s: is a directory%n", source);
                   continue;
               }
               copyFile(source, dest, prompt, preserve);
           }
       }
   }
}
"))
« Last Edit: November 03, 2011, 11:36:11 pm by Deep Thought »




Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: CODE Tags and Description bug reports/suggestion
« Reply #5 on: November 04, 2011, 12:02:34 am »
Would it slow downj the display of massive code boxes though?

Offline Juju

  • Incredibly sexy mare
  • Coder Of Tomorrow
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 5730
  • Rating: +500/-19
  • Weird programmer
    • View Profile
    • juju2143's shed
Re: CODE Tags and Description bug reports/suggestion
« Reply #6 on: November 04, 2011, 12:08:13 am »
The CODE blocks would be way better with a monospaced font.

Another suggestion: use syntax highlighting?

Remember the day the walrus started to fly...

I finally cleared my sig after 4 years you're happy now?
THEGAME
This signature is ridiculously large you've been warned.

The cute mare that used to be in my avatar is Yuki Kagayaki, you can follow her on Facebook and Tumblr.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: CODE Tags and Description bug reports/suggestion
« Reply #7 on: November 04, 2011, 12:27:23 am »
Yeah I have no idea why Netham45 got rid of monospaced fonts for code blocks.