<commit_before>/* v/term.c
**
** This file is in the public domain.
*/
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <unistd.h>
#include <setjmp.h>
#include <gmp.h>
#include <stdint.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <uv.h>
#include <errno.h>
#include <curses.h>
#include <termios.h>
#include <term.h>

#include "all.h"
#include "v/vere.h"

#if 0
static void _term_read_cb(uv_stream_t*, ssize_t, uv_buf_t);
#endif
#if 1
static void _term_poll_cb(uv_poll_t*, c3_i, c3_i);
#endif

#if 0
/* _term_alloc(): libuv buffer allocator.
*/
static uv_buf_t
_term_alloc(uv_handle_t* had_u, size_t len_i)
{
  return uv_buf_init(malloc(len_i), len_i);
}
#endif

/* u2_term_io_init(): initialize terminal.
*/
void 
u2_term_io_init()
{
  if ( u2_no == u2_Host.ops_u.dem ) {
    u2_utty* uty_u = malloc(sizeof(u2_utty));
    c3_i     fid_i = 0;

    //  Initialize event processing.  Rawdog it.
    //
    {
      uty_u->fid_i = fid_i;

#if 0
      uv_tty_init(u2L, &(uty_u->wax_u), fid_i, 1);
      uv_tty_set_mode(&(uty_u->wax_u), 1);
      uv_read_start((uv_stream_t*)&uty_u->wax_u, _term_alloc, _term_read_cb);
#else
      uv_poll_init(u2L, &(uty_u->wax_u), fid_i);
      uv_poll_start(&(uty_u->wax_u), 
                    (UV_READABLE | UV_WRITABLE), 
                    _term_poll_cb);
#endif
    }

    //  Configure horrible stateful terminfo api.
    //
    {
      if ( 0 != setupterm(0, 2, 0) ) {
        c3_assert(!"init-setupterm");
      }
    }
<commit_msg>Realistically reintroduce accurate comment<commit_after>/* v/term.c
**
** This file is in the public domain.
*/
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <unistd.h>
#include <setjmp.h>
#include <gmp.h>
#include <stdint.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <uv.h>
#include <errno.h>
#include <curses.h>
#include <termios.h>
#include <term.h>

#include "all.h"
#include "v/vere.h"

#if 0
static void _term_read_cb(uv_stream_t*, ssize_t, uv_buf_t);
#endif
#if 1
static void _term_poll_cb(uv_poll_t*, c3_i, c3_i);
#endif

#if 0
/* _term_alloc(): libuv buffer allocator.
*/
static uv_buf_t
_term_alloc(uv_handle_t* had_u, size_t len_i)
{
  return uv_buf_init(malloc(len_i), len_i);
}
#endif

/* u2_term_io_init(): initialize terminal.
*/
void 
u2_term_io_init()
{
  if ( u2_no == u2_Host.ops_u.dem ) {
    u2_utty* uty_u = malloc(sizeof(u2_utty));
    c3_i     fid_i = 0;                         //  stdin, yes we write to it...

    //  Initialize event processing.  Rawdog it.
    //
    {
      uty_u->fid_i = fid_i;

#if 0
      uv_tty_init(u2L, &(uty_u->wax_u), fid_i, 1);
      uv_tty_set_mode(&(uty_u->wax_u), 1);
      uv_read_start((uv_stream_t*)&uty_u->wax_u, _term_alloc, _term_read_cb);
#else
      uv_poll_init(u2L, &(uty_u->wax_u), fid_i);
      uv_poll_start(&(uty_u->wax_u), 
                    (UV_READABLE | UV_WRITABLE), 
                    _term_poll_cb);
#endif
    }

    //  Configure horrible stateful terminfo api.
    //
    {
      if ( 0 != setupterm(0, 2, 0) ) {
        c3_assert(!"init-setupterm");
      }
    }

{'fraction_non_alphanumeric': 0.1583909490886235, 'fraction_numerical': 0.014456316781898177, 'mean_word_length': 3.0651340996168583, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '29772', 'n_tokens_mistral': 1445, 'n_tokens_neox': 1402, 'n_words': 267}