Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make using balance mode consistent with mask mode #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions bestline.c
Original file line number Diff line number Diff line change
Expand Up @@ -3612,13 +3612,22 @@ void bestlineMaskModeDisable(void) {
}

/**
* Enables or disables "balance mode".
* Enables "balance mode".
*
* When it is enabled, bestline() will block until parentheses are
* balanced. This is useful for code but not for free text.
*
* @see bestlineBalanceModeDisable()
*/
void bestlineBalanceModeEnable(void) {
balancemode = 1;
}

/**
* Disables "balance mode".
*/
void bestlineBalanceMode(char mode) {
balancemode = mode;
void bestlineBalanceModeDisable(void) {
balancemode = 0;
}

/**
Expand Down
3 changes: 2 additions & 1 deletion bestline.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ void bestlineHistoryFree(void);
void bestlineClearScreen(int);
void bestlineMaskModeEnable(void);
void bestlineMaskModeDisable(void);
void bestlineBalanceMode(char);
void bestlineBalanceModeEnable(void);
void bestlineBalanceModeDisable(void);
void bestlineUserIO(void *userReadFn, void *userWriteFn, void *userPollFn);
void bestlineDisableRawMode(void);
void bestlineFree(void *);
Expand Down
4 changes: 2 additions & 2 deletions example.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ int main(int argc, char **argv) {
} else if (!strncmp(line, "/unmask", 7)) {
bestlineMaskModeDisable();
} else if (!strncmp(line, "/balance", 8)) {
bestlineBalanceMode(1);
bestlineBalanceModeEnable();
} else if (!strncmp(line, "/unbalance", 10)) {
bestlineBalanceMode(0);
bestlineBalanceModeDisable();
} else if (line[0] == '/') {
fputs("Unreconized command: ", stdout);
fputs(line, stdout);
Expand Down