Skip to content

Commit

Permalink
Added --file-extensions to show filename extensions only.
Browse files Browse the repository at this point in the history
  • Loading branch information
acaudwell committed Jul 8, 2010
1 parent 1c8a9f4 commit 61e710d
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 26 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* Added --stop-at-time option to stop Gource after a number of seconds.
* Added --hide 'mouse' option.
* Added --highlight-dirs option.
* Added --file-extensions to show filename extensions only.
* Allow --file-idle-time 0 (files will never expire).
* Allow --start-position 'random' to set a random start position.
* --log-command VCS replaces multiple --log-command-VCS options.
Expand Down
3 changes: 3 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ options:
--file-filter REGEX
Filter out any files matching a specified regular expression.

--file-extensions
Show filename extensions only.

--user-image-dir DIRECTORY
Directory containing .jpg or .png images of users
(eg 'Full Name.png') to use as avatars.
Expand Down
3 changes: 3 additions & 0 deletions data/gource.1
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ Highlight the names of all directories.
\fB\-\-file\-filter REGEX\fR
Filter out any files matching a specified regular expression.
.TP
\fB\-\-file\-extensions\fR
Show filename extensions only.
.TP
\fB\-\-user\-image\-dir DIRECTORY\fR
Directory containing .jpg or .png images of users (eg 'Full Name.png') to use as avatars.
.TP
Expand Down
19 changes: 9 additions & 10 deletions src/dirnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -878,18 +878,17 @@ void RDirNode::drawDirName(const FXFont& dirfont) const{
// project positions of files and directories on the display in 2d
void RDirNode::calcScreenPos() {

if(!gGourceSettings.hide_dirnames) {
screenpos = display.project(vec3f(pos.x, pos.y, 0.0));
}

if(!gGourceSettings.hide_filenames) {
screenpos = display.project(vec3f(pos.x, pos.y, 0.0));

//first pass - calculate positions of names
for(std::list<RFile*>::const_iterator it = files.begin(); it!=files.end(); it++) {
RFile* f = *it;
f->calcScreenPos(pos);
}
//first pass - calculate positions of names
for(std::list<RFile*>::const_iterator it = files.begin(); it!=files.end(); it++) {
RFile* f = *it;

// TODO: different offsets for selected/not selected
if(f->isSelected())
f->calcScreenPos(pos + vec2f(5.5f, -2.0f));
else
f->calcScreenPos(pos + vec2f(5.5f, -1.0f));
}

for(std::list<RDirNode*>::const_iterator it = children.begin(); it != children.end(); it++) {
Expand Down
36 changes: 25 additions & 11 deletions src/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@ RFile::RFile(const std::string & name, const vec3f & colour, const vec2f & pos,

this->fullpath = name;
this->name = name;

path_hash = 0;

setPath();

namelist = glGenLists(1);

font = 0;
setSelected(false);

dir = 0;
Expand Down Expand Up @@ -93,30 +95,40 @@ void RFile::setPath() {
if(pos != std::string::npos) {
path = name.substr(0,pos+1);
name = name.substr(pos+1, std::string::npos);
return;
} else {
path = std::string("");
}

path = std::string("");
//trim name to just extension
if(gGourceSettings.file_extensions) {
int dotsep=0;
if((dotsep=name.rfind(".")) != std::string::npos && dotsep != name.size()-1 && dotsep != 0) {
shortname = name.substr(dotsep+1);
}
}
}

int call_count = 0;


void RFile::setSelected(bool selected) {
if(font.getFTFont()!=0 && this->selected==selected) return;

if(selected) {
font = fontmanager.grab("FreeSans.ttf", 18);
} else {
font = fontmanager.grab("FreeSans.ttf", 11);
}

font.dropShadow(false);
font.roundCoordinates(true);

namewidth = font.getWidth(name.c_str());

Pawn::setSelected(selected);

//pre-compile name display list
glNewList(namelist, GL_COMPILE);
font.draw(0.0f, 0.0f, name);
glEndList();
//glNewList(namelist, GL_COMPILE);
// font.draw(0.0f, 0.0f, (selected || shortname.size()==0) ? name : shortname);
//glEndList();
}

const vec3f& RFile::getNameColour() const{
Expand Down Expand Up @@ -243,8 +255,8 @@ void RFile::drawNameText(float alpha) const {

vec3f drawpos = screenpos;

drawpos.x += 10.0;
drawpos.y -= 10.0;
//drawpos.x += 10.0;
//drawpos.y -= 10.0;

glPushMatrix();

Expand All @@ -254,12 +266,14 @@ void RFile::drawNameText(float alpha) const {
glPushMatrix();
glTranslatef(1.0, 1.0, 0.0);
glColor4f(0.0, 0.0, 0.0, name_alpha * 0.7f);
glCallList(namelist);
//glCallList(namelist);
font.draw(0.0f, 0.0f, (selected || shortname.size()==0) ? name : shortname);
glPopMatrix();

//draw name
glColor4f(nameCol.x, nameCol.y, nameCol.z, name_alpha);
glCallList(namelist);
//glCallList(namelist);
font.draw(0.0f, 0.0f, (selected || shortname.size()==0) ? name : shortname);

glPopMatrix();
}
Expand Down
2 changes: 2 additions & 0 deletions src/file.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ class RFile : public Pawn {

GLuint namelist;

std::string shortname;

void setPath();
const vec3f& getNameColour() const;
void drawNameText(float alpha) const;
Expand Down
4 changes: 2 additions & 2 deletions src/gource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1659,8 +1659,6 @@ void Gource::drawBloom(Frustum &frustum, float dt) {
glBlendFunc (GL_ONE, GL_ONE);

root->drawBloom(frustum, dt);

glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}

void Gource::setMessage(const char* str, ...) {
Expand Down Expand Up @@ -1767,6 +1765,8 @@ void Gource::draw(float t, float dt) {
//draw bloom
drawBloom(frustum, dt);

glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

name_calc_time = SDL_GetTicks();

root->calcScreenPos();
Expand Down
9 changes: 8 additions & 1 deletion src/gource_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ void GourceSettings::help(bool extended_help) {
printf(" --colour-images Colourize user images\n\n");

printf(" -i, --file-idle-time SECONDS Time files remain idle (default: 60)\n");
printf(" --file-filter REGEX Ignore files matching this regexe\n\n");
printf(" --file-filter REGEX Ignore files matching this regexe\n");
printf(" --file-extensions Show filename extensions only\n\n");

printf(" --max-files NUMBER Max number of active files (default: 1000)\n");
printf(" --max-file-lag SECONDS Max time files of a commit can take to appear\n\n");
Expand Down Expand Up @@ -184,6 +185,7 @@ GourceSettings::GourceSettings() {
arg_types["hide-mouse"] = "bool";
arg_types["highlight-all-users"] = "bool";
arg_types["highlight-dirs"] = "bool";
arg_types["file-extensions"] = "bool";

arg_types["disable-auto-rotate"] = "bool";
arg_types["disable-auto-skip"] = "bool";
Expand Down Expand Up @@ -314,6 +316,7 @@ void GourceSettings::setGourceDefaults() {
delete (*it);
}
file_filters.clear();
file_extensions = false;
}

void GourceSettings::commandLineOption(const std::string& name, const std::string& value) {
Expand Down Expand Up @@ -901,6 +904,10 @@ void GourceSettings::importGourceSettings(ConfFile& conffile, ConfSection* gourc
}
}

if(gource_settings->getBool("file-extensions")) {
file_extensions=true;
}

if((entry = gource_settings->getEntry("file-filter")) != 0) {

ConfEntryList* filters = gource_settings->getEntries("file-filter");
Expand Down
1 change: 1 addition & 0 deletions src/gource_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ class GourceSettings : public SDLAppSettings {
std::vector<std::string> highlight_users;
std::vector<std::string> follow_users;
std::vector<Regex*> file_filters;
bool file_extensions;

GourceSettings();

Expand Down
4 changes: 2 additions & 2 deletions src/pawn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ Pawn::Pawn(std::string name, vec2f pos, int tagid) {

shadow = false;

this->shadowOffset = vec2f(2.0, 2.0);
namewidth = 0;

this->shadowOffset = vec2f(2.0, 2.0);
this->elapsed = 0.0;
this->fadetime = 1.0;
this->nametime = 5.0;
Expand Down Expand Up @@ -109,7 +110,6 @@ void Pawn::drawNameText(float alpha) const {

glColor4f(nameCol.x, nameCol.y, nameCol.z, alpha);

float namewidth = font.getWidth(name);
font.draw(pos.x - ((float)namewidth/2.0), pos.y - size*1.2, name.c_str()); // above player
}
}
Expand Down
1 change: 1 addition & 0 deletions src/pawn.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class Pawn : public QuadItem {
std::string getName();

virtual void setSelected(bool selected);
bool isSelected() { return selected; };

void setHidden(bool hidden){ this->hidden = hidden; }
bool isHidden() const { return hidden; }
Expand Down

0 comments on commit 61e710d

Please sign in to comment.