Skip to content

Commit

Permalink
Refactor: Renamed Con_CursorPosition and Con_ConsoleBuffer to
Browse files Browse the repository at this point in the history
Con_CommandLineCursorPosition and Con_HistoryBuffer respectively.
  • Loading branch information
danij-deng committed Jul 16, 2011
1 parent a48be67 commit 7e95455
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 28 deletions.
8 changes: 5 additions & 3 deletions doomsday/engine/portable/include/con_main.h
Expand Up @@ -177,11 +177,13 @@ boolean Con_IsLocked(void);

boolean Con_InputMode(void);

uint Con_CursorPosition(void);

char* Con_CommandLine(void);

cbuffer_t* Con_ConsoleBuffer(void);
uint Con_CommandLineCursorPosition(void);

cbuffer_t* Con_HistoryBuffer(void);

void Con_ResizeHistoryBuffer(void);

fontnum_t Con_Font(void);

Expand Down
2 changes: 1 addition & 1 deletion doomsday/engine/portable/src/con_busy.c
Expand Up @@ -566,7 +566,7 @@ void Con_BusyDrawConsoleOutput(void)
float y, topY;
uint i, newCount;

buffer = Con_ConsoleBuffer();
buffer = Con_HistoryBuffer();
newCount = GetBufLines(buffer, visibleBusyLines);
nowTime = Sys_GetRealSeconds();
if(newCount > 0)
Expand Down
46 changes: 27 additions & 19 deletions doomsday/engine/portable/src/con_main.c
Expand Up @@ -226,25 +226,33 @@ void Con_Register(void)
Con_DataRegister();
}

static void resizeHistoryBuffer(void)
void Con_ResizeHistoryBuffer(void)
{
assert(ConsoleInited);
{
int maxLength = 70;
float cw;

FR_SetFont(consoleFont);
FR_LoadDefaultAttrib();
FR_SetTracking(consoleFontTracking);
FR_SetLeading(consoleFontLeading);

cw = (FR_TextWidth("AA") * consoleFontScale[0]) / 2;
if(0 != cw)
if(!ConsoleInited)
{
maxLength = MIN_OF(theWindow->width / cw - 2, 250);
Con_Error("Con_ResizeHistoryBuffer: Console is not yet initialised.");
exit(1); // Unreachable.
}
Con_BufferSetMaxLineLength(Con_ConsoleBuffer(), maxLength);

if(!novideo && !isDedicated)
{
float cw;

FR_SetFont(consoleFont);
FR_LoadDefaultAttrib();
FR_SetTracking(consoleFontTracking);
FR_SetLeading(consoleFontLeading);

cw = (FR_TextWidth("AA") * consoleFontScale[0]) / 2;
if(0 != cw)
{
maxLength = MIN_OF(theWindow->width / cw - 2, 250);
}
}

Con_BufferSetMaxLineLength(Con_HistoryBuffer(), maxLength);
}

static void PrepareCmdArgs(cmdargs_t *cargs, const char *lpCmdLine)
Expand Down Expand Up @@ -427,12 +435,12 @@ char* Con_CommandLine(void)
return cmdLine;
}

cbuffer_t* Con_ConsoleBuffer(void)
cbuffer_t* Con_HistoryBuffer(void)
{
return histBuf;
}

uint Con_CursorPosition(void)
uint Con_CommandLineCursorPosition(void)
{
return cmdCursor;
}
Expand All @@ -451,7 +459,7 @@ void Con_SetFont(fontnum_t font)
if(consoleFont == font)
return;
consoleFont = font;
resizeHistoryBuffer();
Con_ResizeHistoryBuffer();
}

con_textfilter_t Con_PrintFilter(void)
Expand Down Expand Up @@ -486,7 +494,7 @@ void Con_SetFontScale(float scaleX, float scaleY)
consoleFontScale[0] = MAX_OF(.5f, scaleX);
if(scaleY > 0.0001f)
consoleFontScale[1] = MAX_OF(.5f, scaleY);
resizeHistoryBuffer();
Con_ResizeHistoryBuffer();
}

float Con_FontLeading(void)
Expand All @@ -501,7 +509,7 @@ void Con_SetFontLeading(float value)
if(!ConsoleInited)
Con_Error("Con_SetFontLeading: Console is not yet initialised.");
consoleFontLeading = MAX_OF(.1f, value);
resizeHistoryBuffer();
Con_ResizeHistoryBuffer();
}

int Con_FontTracking(void)
Expand All @@ -516,7 +524,7 @@ void Con_SetFontTracking(int value)
if(!ConsoleInited)
Con_Error("Con_SetFontTracking: Console is not yet initialised.");
consoleFontTracking = MAX_OF(0, value);
resizeHistoryBuffer();
Con_ResizeHistoryBuffer();
}

/**
Expand Down
9 changes: 4 additions & 5 deletions doomsday/engine/portable/src/rend_console.c
Expand Up @@ -589,8 +589,8 @@ static void drawConsole(float consoleAlpha)
static const cbline_t** lines = 0;
static int bufferSize = 0;

cbuffer_t* buffer = Con_ConsoleBuffer();
uint cmdCursor = Con_CursorPosition();
cbuffer_t* buffer = Con_HistoryBuffer();
uint cmdCursor = Con_CommandLineCursorPosition();
char* cmdLine = Con_CommandLine();
float scale[2], y, fontScaledY, gtosMulY = theWindow->height / 200.0f;
char buff[LOCALBUFFSIZE];
Expand Down Expand Up @@ -714,9 +714,8 @@ static void drawConsole(float consoleAlpha)

y = ConsoleY * gtosMulY - (lineHeight * scale[1]) - textOffsetY;

cmdLineLength = strlen(cmdLine);
maxLineLength = Con_BufferMaxLineLength(buffer);
maxLineLength -= 1; /*prompt length*/
cmdLineLength = (uint)strlen(cmdLine);
maxLineLength = Con_BufferMaxLineLength(buffer) - 1/*prompt length*/;

if(cmdLineLength >= maxLineLength)
{
Expand Down

0 comments on commit 7e95455

Please sign in to comment.