📄 tbuffer.c
字号:
//---------------------------------------------------------
/*
File name: Tbuffer.h
Comments: This file contains the implementation of the
text_buffer type.
*/
//---------------------------------------------------------
// Include files.
#include "Tbuffer.h"
#include <stdlib.h>
// End include files.
//---------------------------------------------------------
//---------------------------------------------------------
// Macros
// This macro has a problem.
#define SelectValue3(conditionValue, \
selectionValue1, \
response1, \
selectionValue2, \
response2, \
selectionValue3, \
response3) \
(conditionValue == selectionValue1) ? \
response1 : \
(conditionValue == selectionValue2) ? \
response2 : response3
// End macros
//---------------------------------------------------------
text_buffer_error TextBufferSetRow(text_buffer buffer,
int row,
text_string theString)
{
text_buffer_error errorStatus = TBE_NO_ERROR;
// If the row number is out of range...
if ((row<0) || (row>=TEXT_BUFFER_LENGTH))
{
// Set an error
}
else
{
// Set the row to the specified string.
}
return (errorStatus);
}
void TextBufferGetRow(text_buffer buffer,
int row,
text_string theString)
{
int i;
// If the row number is in range...
if ((row>=0) && (row<TEXT_BUFFER_LENGTH))
{
// Copy the characters in the row
for (i=0;buffer[row][i]!='\0';i++)
{
theString[i] = buffer[row][i];
}
theString[i]='\0';
}
}
text_buffer_error TextBufferSetCharacter(text_buffer buffer,
int row,int column,
char theCharacter)
{
text_buffer_error errorStatus = TBE_NO_ERROR;
text_string_error stringError;
// If the row or column number is out of range...
if ((row<0) || (row>=TEXT_BUFFER_LENGTH) ||
(column<0) || (column>=TEXT_STRING_MAX_LENGTH))
{
// Set an error.
errorStatus = TBE_INDEX_OUT_OF_RANGE;
}
else
{
stringError = TextStringSetCharacter(buffer[row],
theCharacter,
column);
// If the character not could be set...
if (stringError!= TSE_NO_ERROR)
{
errorStatus =
SelectValue3(stringError,
TSE_INVALID_CHARACTER,
TBE_INVALID_CHARACTER,
TSE_INDEX_AFTER_END_OF_STRING,
TBE_INDEX_OUT_OF_RANGE,
TSE_INDEX_OUT_OF_RANGE,
TBE_INDEX_OUT_OF_RANGE);
}
}
return (errorStatus);
}
int TextBufferGetCharacter(text_buffer buffer,
int row,int column)
{
int theCharacter = -1;
// If the row and column numbers are in range...
// Get the character
return (theCharacter);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -