Quake II RTX doxygen  1.0 dev
field.c File Reference
#include "shared/shared.h"
#include "common/common.h"
#include "common/field.h"
#include "client/client.h"
#include "client/keys.h"
#include "client/video.h"
#include "refresh/refresh.h"

Go to the source code of this file.

Functions

void IF_Init (inputField_t *field, size_t visibleChars, size_t maxChars)
 
void IF_Clear (inputField_t *field)
 
void IF_Replace (inputField_t *field, const char *text)
 

Function Documentation

◆ IF_Clear()

void IF_Clear ( inputField_t *  field)

Definition at line 56 of file field.c.

57 {
58  memset(field->text, 0, sizeof(field->text));
59  field->cursorPos = 0;
60 }

Referenced by Con_ClearTyping(), Key_Message(), Prompt_Action(), and Prompt_Clear().

◆ IF_Init()

void IF_Init ( inputField_t *  field,
size_t  visibleChars,
size_t  maxChars 
)

Definition at line 36 of file field.c.

37 {
38  memset(field, 0, sizeof(*field));
39 
40  if (maxChars >= sizeof(field->text)) {
41  maxChars = sizeof(field->text) - 1;
42  }
43  if (visibleChars > maxChars) {
44  visibleChars = maxChars;
45  }
46 
47  field->maxChars = maxChars;
48  field->visibleChars = visibleChars;
49 }

Referenced by Con_Init(), Field_Push(), and Push().

◆ IF_Replace()

void IF_Replace ( inputField_t *  field,
const char *  text 
)

Definition at line 67 of file field.c.

68 {
69  if (field->maxChars && text) {
70  size_t len = Q_strlcpy(field->text, text, field->maxChars + 1);
71  field->cursorPos = len >= field->maxChars ? field->maxChars - 1 : len;
72  } else {
73  field->text[0] = 0;
74  field->cursorPos = 0;
75  }
76 }

Referenced by Field_Push(), Prompt_CompleteHistory(), Prompt_HistoryDown(), Prompt_HistoryUp(), Push(), and start_message_mode().

Q_strlcpy
size_t Q_strlcpy(char *dst, const char *src, size_t size)
Definition: shared.c:715