trying out tabs with underscores removed

This commit is contained in:
Ben Fry
2022-08-02 13:19:26 -04:00
parent c81a44440f
commit e7504f1c3b
3 changed files with 21 additions and 16 deletions
+9 -3
View File
@@ -135,12 +135,18 @@ public class SketchCode {
}
/** Get the name of this file with its extension removed. */
/**
* Get the name of this file with its extension removed.
* Because of other uses of this method, this is not a good place
* to do things like swap underscores for spaces.
*/
public String getPrettyName() {
String name = file.getName();
// remove the extension from the name
int dot = name.lastIndexOf('.');
// should absolutely have a dot, but better not to make that
// assumption in case we later decide to allow things like README
// should have a dot in all current scenarios, but better not to make
// that assumption in case we later decide to allow things like README
return (dot != -1) ? name.substring(0, dot) : name;
}
+8 -12
View File
@@ -31,11 +31,7 @@ import java.util.Arrays;
import javax.swing.*;
import processing.app.Language;
import processing.app.Messages;
import processing.app.Platform;
import processing.app.Sketch;
import processing.app.SketchCode;
import processing.app.*;
/**
@@ -201,14 +197,14 @@ public class EditorHeader extends JComponent {
tab.textVisible = true;
tab.lastVisited = code.lastVisited();
tab.text = code.getFileName();
// hide extensions for .pde files
boolean hide = editor.getMode().hideExtension(code.getExtension());
tab.text = hide ? code.getPrettyName() : code.getFileName();
// if modified, add the li'l glyph next to the name
// if (code.isModified()) {
// tab.text += " \u00A7";
// }
if (editor.getMode().hideExtension(code.getExtension())) {
tab.text = code.getPrettyName();
if (Preferences.getBoolean("sketch.name.replace_underscore")) {
tab.text = tab.text.replace('_', ' ');
}
}
tab.textWidth = (int)
font.getStringBounds(tab.text, g2.getFontRenderContext()).getWidth();
+4 -1
View File
@@ -225,9 +225,12 @@ editor.untitled.prefix=sketch_
# If you change this, be careful that this will work with your language
# settings. For instance, MMMdd won't work on Korean-language systems
# because it'll insert non-ASCII characters and break the environment.
# http://code.google.com/p/processing/issues/detail?id=283
# https://github.com/processing/processing/issues/322
editor.untitled.suffix=yyMMdd
# replace underscores in .pde file names with spaces
sketch.name.replace_underscore = true
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!