/*
	Schrodinger's Box Haven  code version -0.1 alpha
        Copyright (C) 1994, Gordon Chan

	You can do whatever ya want with this code as long as you leave this
        copyright & disclaimer intact.  You can hack it up all you want, etc...
        No guarantees.

	Send comments, flames, bug reports, etc ... to
		au233@freenet.carleton.ca  <---- (preferred address for now)
		gjc@achilles.net
		gchan@ccs.carleton.ca
*/


/* Here's the copyrights & disclaimers from the Opium Den and unixCB codes */

/* Opium Den */
/*
  val's haven code v -0.85

        Copyright (C) 1994 Joel Ward

        Warranty:
                Don't blame me for anything.

        You can do whatever the fuck you want with this code as long as you
don't remove this copyright/disclaimer notice.
*/

/* unixCB */
/*
  
  cbd.c
  
  "cbd.c" is the main code for the CB simulator.
  
  Copyright (c) 1992, Gary Grossman.  All rights reserved.
  Send comments and questions to: garyg@soda.berkeley.edu
  
  */

#include <stdio.h>
#include <string.h>

#include "linked_lists.h"


void toggle_monitor(user, text)
  struct user *user;
  char *text;
{
  toggle_user(user, Fmonitor);

  if(is_user(user, Fmonitor))
    write_user(user->desc, ">> Monitoring of main channel is on.\r\n");
  else
    write_user(user->desc, ">> Monitoring of main channel is off.\r\n");
}		


void toggle_mess(user, text)
  struct user *user;
  char *text;
{
  toggle_user(user, Fmess_supp);

  if (is_user(user, Fmess_supp))
    write_user(user->desc, ">> Login and logout messages are suppressed.\r\n");
  else
    write_user(user->desc, ">> Login and logout messages are enabled.\r\n");
}		


void toggle_hush(user, text)
  struct user *user;
  char *text;
{
  toggle_user(user, Fhush);

  if (is_user (user, Fhush))
    write_user(user->desc, ">> Yells are suppressed.\r\n");
  else
    write_user(user->desc, ">> Yells are enabled.\r\n");
}		


void toggle_hilite(user, text)
  struct user *user;
  char *text;
{
  toggle_user(user, Fhilite);

  if (is_user (user, Fhilite))
    write_user(user->desc, ">> Private messages will be hilighted.\r\n");
  else
    write_user(user->desc, ">> Private message hilite off.\r\n");
}		


static char *colname[7] = {"<r>ed", "<g>reen", "<y>ellow", "<b>lue", 
                            "<m>agenta", "<c>yan", "<n>o colour"};

void colour_menu(user, buffer)
  struct user *user;
  char *buffer;
{
  char tempbuffer[160];

  sprintf(tempbuffer, 
   "Which colour would you like?\r\n %s, %s, %s, %s, %s, %s,  %s\r\n Press <CR> for a default colour of %s.\r\n",
   colname[0], colname[1], colname[2], colname[3], colname[4], colname[5],
   colname[6], colname[user->colour-31]);
  strcpy(buffer, tempbuffer);
}


void toggle_colour(user, text)
  struct user *user;
  char *text;
{
  char tempbuffer[80];

  toggle_user(user, Fcolour);

  if (is_user(user, Fcolour)) {
    toggle_user(user, Fcomm_line);
    switch (*text) {
    case 'r':
      user->colour = 31;
      break;
    case 'g':
      user->colour = 32;
      break;
    case 'y':
      user->colour = 33;
      break;
    case 'b':
      user->colour = 34;
      break;
    case 'm':
      user->colour = 35;
      break;
    case 'c':
      user->colour = 36;
      break;
    case 'n':
      toggle_user(user, Fcolour);
      write_user(user->desc, ">> Huh?  No colour? :) :)\r\n");
      user->linecharmax = INPUTMAX;
      return;
      break;
    case '\0':
       break;
    default:
      toggle_user(user, Fcolour);
      write_user(user->desc, ">> What colour was that suppose to be?  Try again.\r\n");
      user->linecharmax = INPUTMAX;
      return;
      break;    
    }
    sprintf (tempbuffer, ">> You are now the TECHNO colour %s!\r\n", 
     colname[user->colour-31]);
    write_user(user->desc, tempbuffer);
  } else
    write_user(user->desc, ">> TECHNO colour mode off.\r\n");
  user->linecharmax = INPUTMAX;
}		



void toggle_linewrap(user, text)
  struct user *user;
  char *text;
{
  char tempbuffer[80];
  int width = atoi(text);
  toggle_user(user, Flinewrap);

  if(is_user(user, Flinewrap)) {
    toggle_user(user, Fcomm_line);
    if (width < 20 || width > 120) {
      toggle_user(user, Flinewrap);
      write_user(user->desc, ">> Valid widths range from 20 to 120.  Try again.\r\n");
    } else {
      user->line_width = width;
      sprintf(tempbuffer, ">> Linewrap width has been set to %d.\r\n", width);
      write_user(user->desc, tempbuffer);
    }
  } else
    write_user(user->desc, ">> Linewrap is turned off.\r\n");
  user->linecharmax = INPUTMAX;
}		

