mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
selection: break out isword() to a new file
This commit is contained in:
parent
f1c876884a
commit
198529525c
4 changed files with 32 additions and 21 deletions
|
|
@ -75,6 +75,7 @@ executable(
|
||||||
'input.c', 'input.h',
|
'input.c', 'input.h',
|
||||||
'log.c', 'log.h',
|
'log.c', 'log.h',
|
||||||
'main.c',
|
'main.c',
|
||||||
|
'misc.c', 'misc.h',
|
||||||
'osc.c', 'osc.h',
|
'osc.c', 'osc.h',
|
||||||
'render.c', 'render.h',
|
'render.c', 'render.h',
|
||||||
'search.c', 'search.h',
|
'search.c', 'search.h',
|
||||||
|
|
|
||||||
24
misc.c
Normal file
24
misc.c
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
#include "misc.h"
|
||||||
|
|
||||||
|
#include <wctype.h>
|
||||||
|
|
||||||
|
bool
|
||||||
|
isword(wchar_t wc, bool spaces_only)
|
||||||
|
{
|
||||||
|
if (spaces_only)
|
||||||
|
return iswgraph(wc);
|
||||||
|
|
||||||
|
switch (wc) {
|
||||||
|
default: return iswgraph(wc);
|
||||||
|
|
||||||
|
case L'(': case L')':
|
||||||
|
case L'[': case L']':
|
||||||
|
case L'{': case L'}':
|
||||||
|
case L'<': case L'>':
|
||||||
|
case L'│': case L'|':
|
||||||
|
case L',':
|
||||||
|
case L'`': case L'"': case L'\'':
|
||||||
|
case L':':
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
6
misc.h
Normal file
6
misc.h
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <wchar.h>
|
||||||
|
|
||||||
|
bool isword(wchar_t wc, bool spaces_only);
|
||||||
22
selection.c
22
selection.c
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
#include "async.h"
|
#include "async.h"
|
||||||
#include "grid.h"
|
#include "grid.h"
|
||||||
|
#include "misc.h"
|
||||||
#include "render.h"
|
#include "render.h"
|
||||||
#include "vt.h"
|
#include "vt.h"
|
||||||
|
|
||||||
|
|
@ -222,27 +223,6 @@ selection_cancel(struct terminal *term)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
|
||||||
isword(wint_t c, bool spaces_only)
|
|
||||||
{
|
|
||||||
if (spaces_only)
|
|
||||||
return !iswspace(c);
|
|
||||||
|
|
||||||
switch (c) {
|
|
||||||
default: return !iswspace(c);
|
|
||||||
|
|
||||||
case L'{': case L'}':
|
|
||||||
case L'[': case L']':
|
|
||||||
case L'(': case L')':
|
|
||||||
case L'`':
|
|
||||||
case L'\'':
|
|
||||||
case L'"':
|
|
||||||
case L',': case L'.':
|
|
||||||
case L':': case L';':
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
selection_mark_word(struct terminal *term, int col, int row, bool spaces_only,
|
selection_mark_word(struct terminal *term, int col, int row, bool spaces_only,
|
||||||
uint32_t serial)
|
uint32_t serial)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue