Change text font to greater one in this very good MOTIF texteditor ?


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Change text font to greater one in this very good MOTIF texteditor ?
# 1  
Old 10-25-2019
Change text font to greater one in this very good MOTIF texteditor ?

Hi,
i have here found a very good texteditor source code programmed in the MOTIF GUI language.
For myself i need NOTHING else to program.
To start from a very easy point of view i want to RUN this editor on my LINUX machine and type simple C code.

The reason for this post is that the text font of this editor is to small.
I am at this point of knowledge not able to find the position in the code to CHANGE THE FONT SIZE.
Can someone help ???

Kindly Regards
SM

HERE IS THE SOURCE CODE :
Code:
// Name     : Motif Text Editor
// Author   : Terrence Ma
// Email    : terrence@terrence.com
// Web      : http://www.terrence.com
// Date     : V1.0 11/16/2002
// Modified : CDE and Motif, scrolled.c p.225

/*
 * Program:   scrolledtext - This program illustrates the use of a
 *                       scrolled text widget.
 * 
 * Author :   Antonino N. Mione
 *
 * Date   :   22-Nov-1995
 *
 */

#include <sys/types.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>

/* X and Motif headers */
#include <X11/Intrinsic.h>
#include <Xm/Label.h>
#include <Xm/MainW.h>
#include <Xm/Form.h>
#include <Xm/MessageB.h>
#include <Xm/PushB.h>
#include <Xm/RowColumn.h>
#include <Xm/Text.h>
#include <Xm/Separator.h>
#include <Xm/FileSB.h>
#include <Xm/Xm.h>

/*
 * Some commonly used buffer sizes for strings and data.
 */
#define SMALL_BUF_SIZE 64
#define LARGE_BUF_SIZE 256
#define HUGE_BUF_SIZE 1024

#define MAX_BUTTONS 3

#define MAX_READ 2048
#define MAX_WRITE 2048

/* Some key X, toolkit, and Motif variables */
/* Widget ids */
Widget toplevel;              /* toplevel shell widget id                   */
Widget buttons[ MAX_BUTTONS ]; /* Buttons for functions: WorkingDialog, etc. */
Widget mainw;                 /* Main window to hold everything             */
Widget form;                  /* Form widget                                */
Widget scrolledtext;          /* Scrolled Text widget                       */
Widget separate;              /* Separator widget                           */
Widget rowcol;                /* Rowcol for quit button                     */
Widget filesb;                /* File selection box widget                  */
Widget msgtext;               /* Text widget for the message area           */

XtAppContext app_context;     /* Application context info (used by toolkit) */

/*
 * Following are button labels and enumerated variables for button
 * choices.
 */
char *buttonlabels[] = { "Open", "Save", "Quit" };
enum button_nums { opOpen=1, opSave, opQuit };

#define open_button 0
#define save_button 1
#define quit_button 2

enum file_operations { none, openning, saving };

enum file_operations fileop;

#define okButton 0
#define cancelButton 1

FILE *filehandle;

/* Prototypes */
void msgText ( char * );
Boolean read_file ( FILE *filehandle );
Boolean save_file ( FILE *filehandle );
void buttonCallback ( Widget, XtPointer, XtPointer );
void filesbButtonCallback ( Widget, XtPointer, XtPointer );
void init_widgets ( void );
int main ( int, char ** );


/*
 * procedure    :   msgText - Write a message to the message area.
 *
 * arguments    :   msg ( in / (char *) ) - Text to be written to message area.
 *
 * return       :   void
 *
 * side effects :   
 */
void msgText ( char *msg )
{
  XmTextPosition text_pos;                /* Last position in text area      */

  /*
   * Find last position used in the message area and insert the new message
   * there.
   */
  text_pos = XmTextGetLastPosition ( msgtext );
  XmTextInsert ( msgtext, text_pos, msg );
}

/*
 * procedure    :   read_file - This procedure reads a file into the
 *                         scrolled text widget.
 *
 * arguments    :   filehandle - The filehandle from which to read.
 *
 * return       :   True/False indicating the success of the operation.
 *
 * side effects :   none.
 */
Boolean read_file ( FILE *filehandle )
{
  XmTextPosition pos = 0;     /* Last position filled in text widget     */
  char buf[ MAX_READ ];       /* Buffer for reading characters from file */
  
  /*
   * Clear any text in the scrolled text widget.
   */
  XmTextSetString ( scrolledtext, "" );
  /*
   * As long as fgets succeeds, continue appending what is read to the
   * scrolled text widget's value. Use pos to track last filled position
   * so the XmTextInsert function appends to the existing value.
   */
  while ( fgets ( buf, MAX_READ, filehandle ) != NULL )
    {
      XmTextInsert ( scrolledtext, pos, buf );
      pos += strlen ( buf );
    }
  return True;
}

/*
 * procedure    :   save_file - This procedure writes the contents of the
 *                         scrolled text widget into a file.
 *
 * arguments    :   filehandle - The filehandle to which to write.
 *
 * return       :   True/False indicating the success of the operation.
 *
 * side effects :   none.
 */
Boolean save_file ( FILE *filehandle )
{
  char *stext_string;          /* Temporary storage for text widgets' value */
  int status;                  /* Status returned from fputs                */
  
  /*
   * Fetch the entire text value from the widget and write it to the file
   * in one operation.
   */
  stext_string = XmTextGetString ( scrolledtext );
  status = fputs ( stext_string, filehandle );
  XtFree ( stext_string );
  /*
   * Check the return status from the file write. If it succeeded, clear
   * the widget's value and return true. Otherwise, return false.
   */
  if ( status )
    {
      XmTextSetString ( scrolledtext, "" );
      return True;
    }
  else
    {
      return False;
    }
}

/*
 * procedure    :   buttonCallback - Callback when user activates a button.
 *
 * arguments    :   widgetId ( in / (Widget) ) - widgetId of widget causing
 *                      the callback.
 *                  clientData ( in / (XtPointer) ) - value passed to routine
 *                      by the widget.
 *                  cbr ( in / (XtPointer) ) - the callbackRecord. This
 *                      contains additional information pertinent to the
 *                      event causing the callback.
 *
 * return       :   none.
 *
 * side effects :   none.
 */
void buttonCallback ( Widget widgetId,
		      XtPointer clientData,
		      XtPointer cbr )
{
  /* Cast callback record and client data to the correct type.              */
  XmPushButtonCallbackStruct *callbackRecord =
                                 (XmPushButtonCallbackStruct *) cbr;
  enum button_nums button_num = (enum button_nums) clientData;
  XmString tempCString;
  Arg args[ 10 ];
  Cardinal arg_count;
  
  /*
   * Select process based on button number.
   */
  switch ( button_num )
    {
      case opOpen:                 /* Open a file */
        fileop = openning;
	/*
	 * Configure the file selection dialog and post it.
	 */
#if XmVERSION >= 2
	tempCString = XmStringGenerate ( "File to open",
					 NULL,
					 XmCHARSET_TEXT,
					 NULL );
#else
	tempCString = XmStringCreateLocalized ( "File to open" );
#endif
	XtVaSetValues ( filesb,
		        XmNselectionLabelString, tempCString,
		        NULL );
	XtManageChild ( filesb );
	XmStringFree ( tempCString );
        break;
      case opSave:                 /* Save text to a file */
	fileop = saving;
	/*
	 * Configure the file selection dialog and post it.
	 */
#if XmVERSION >= 2
	tempCString = XmStringGenerate ( "File to save",
					 NULL,
					 XmCHARSET_TEXT,
					 NULL );
#else
	tempCString = XmStringCreateLocalized ( "File to save" );
#endif
	XtVaSetValues ( filesb,
		        XmNselectionLabelString, tempCString,
		        NULL );
	XtManageChild ( filesb );
	XmStringFree ( tempCString );
        break;
      case opQuit:                 /* Exit the application */
	exit ( 0 );
	break;
    }

  return;
}

/*
 * procedure    :   filesbButtonCallback - This routine is called when a
 *                                  file selection box button has been
 *                                  activated.
 *
 * arguments    :   none
 *
 * return       :   void
 *
 * side effects :   none
 */

void filesbButtonCallback ( Widget widgetId,
		      XtPointer clientData,
		      XtPointer cbr )
{
  /* Cast callback record and client data to the correct type.              */
  XmFileSelectionBoxCallbackStruct *callbackRecord =
                                 (XmFileSelectionBoxCallbackStruct *) cbr;
  int button_num = (int) clientData;
  char *filename;
  Boolean status;
  
  /* Convert the filename to ascii */
  status = XmStringGetLtoR ( callbackRecord->value, XmFONTLIST_DEFAULT_TAG, &filename );

  /*
   * If there was an error retrieving the filename, ring the bell and return.
   * If the filename was empty, do the same.
   */
  if ( !status )
    {
      XBell ( XtDisplay ( toplevel ), 50 );
      return;
    }
  if ( !*filename )
    {
      XtFree ( filename );
      XBell ( XtDisplay ( toplevel ), 50 );
      return;
    }
  /*
   * If the user clicked 'ok', check whether we are openning or saving to
   * the file. Perform the appropriate operations for each.
   */
  if ( button_num == okButton )
    {
      if ( fileop == openning )
	{
	  filehandle = fopen ( filename, "r" );
	  read_file ( filehandle );
	  fclose ( filehandle );
	}
      else
	{
	  filehandle = fopen ( filename, "w" );
	  save_file ( filehandle );
	  fclose ( filehandle );
	}
      fileop = none;
    }
}

/*
 * procedure    :   init_widgets - This routine initializes all of the
 *                                 widgets for the application.
 *
 * arguments    :   none
 *
 * return       :   void
 *
 * side effects :   none
 */

void init_widgets ( void )
{
  Arg args[ 10 ];                      /* Argument array for widget creation */
  Cardinal arg_count;                  /* Count of valid arguments           */
  char tempName[ LARGE_BUF_SIZE ];     /* Work space to build widget names   */
  int temp_idx;                        /* Loop index                         */
  int button_num;                      /* Button num for activate callback   */
  Widget temp_id_hs, temp_id_vs;

  /*
   * Create a main window.
   */
  arg_count = 0;
  mainw = XmCreateMainWindow ( toplevel,
			       "mainw",
			       args,
			       arg_count );

  /*
   * Create the form to hold everything else.
   */
  arg_count = 0;
  form = XmCreateForm ( mainw,
		        "form",
		        args,
		        arg_count );
/*
  XtManageChild ( form );
*/

  /*
   * Create a scrolled text widget as a child of the form.
   * Make it an editable Multi-line text widget (24x80).
   */
  arg_count = 0;
/*
  XtSetArg ( args[ arg_count ], XmNrows, 24 );
  arg_count++;
  XtSetArg ( args[ arg_count ], XmNcolumns, 80 );
  arg_count++;
*/
  XtSetArg ( args[ arg_count ], XmNeditMode, XmMULTI_LINE_EDIT );
  arg_count++;
  XtSetArg ( args[ arg_count ], XmNeditable, True );
  arg_count++;
  XtSetArg ( args[ arg_count ], XmNtopAttachment, XmATTACH_FORM );
  arg_count++;
  XtSetArg ( args[ arg_count ], XmNleftAttachment, XmATTACH_FORM );
  arg_count++;
  XtSetArg ( args[ arg_count ], XmNrightAttachment, XmATTACH_FORM );
  arg_count++;
  XtSetArg ( args[ arg_count ], XmNbottomAttachment, XmATTACH_NONE );
  arg_count++;
  scrolledtext = XmCreateScrolledText ( form,
				        "scrolledtext",
				        args,
				        arg_count );
  /* Manage the scrolledtext widget */
  XtManageChild ( scrolledtext );
  
  /*
   * Create a separator to separate the scrolledtext and rowcolumn widgets.
   */
  arg_count = 0;
  XtSetArg ( args[ arg_count ], XmNtopAttachment, XmATTACH_WIDGET );
  arg_count++;
  XtSetArg ( args[ arg_count ], XmNtopWidget, scrolledtext );
  arg_count++;
  XtSetArg ( args[ arg_count ], XmNleftAttachment, XmATTACH_FORM );
  arg_count++;
  XtSetArg ( args[ arg_count ], XmNrightAttachment, XmATTACH_FORM );
  arg_count++;
  XtSetArg ( args[ arg_count ], XmNbottomAttachment, XmATTACH_NONE );
  arg_count++;
  separate = XmCreateSeparator ( form,
				 "separate",
				 args,
				 arg_count );
  XtManageChild ( separate );
  /*
   * Create a rowcolumn widget as a child of the main window to hold any
   * buttons.
   */ 
  arg_count = 0;
  XtSetArg ( args[ arg_count ], XmNtopAttachment, XmATTACH_WIDGET );
  arg_count++;
  XtSetArg ( args[ arg_count ], XmNtopWidget, separate );
  arg_count++;
  XtSetArg ( args[ arg_count ], XmNleftAttachment, XmATTACH_FORM );
  arg_count++;
  XtSetArg ( args[ arg_count ], XmNrightAttachment, XmATTACH_FORM );
  arg_count++;
  XtSetArg ( args[ arg_count ], XmNbottomAttachment, XmATTACH_FORM );
  arg_count++;
  XtSetArg ( args[ arg_count ], XmNorientation, XmHORIZONTAL );
  arg_count++;
  rowcol = XmCreateRowColumn ( form,
			       "rowcol",
			       args,
			       arg_count );
  XtManageChild ( rowcol );

  /*
   * For each item in buttonlabels,
   *    - generate a name for the new button widget.
   *    - create a button child for the rowcolumn
   *    - add an activate callback.
   *    - manage the new button.
   */
  for ( temp_idx = 0; temp_idx < XtNumber ( buttonlabels ); temp_idx++ )
    {
      button_num = temp_idx + 1;
      sprintf ( tempName, "button_%d", button_num );
      arg_count = 0;
      buttons[ temp_idx ] = XmCreatePushButton ( rowcol,
						 tempName,
						 args,
						 arg_count );
      XtAddCallback ( buttons[ temp_idx ],
		      XmNactivateCallback,
		      buttonCallback,
		      (XtPointer) button_num );
      XtManageChild ( buttons[ temp_idx ] );
    }  

  /*
   * Create a text widget for the message area.
   */
  arg_count = 0;
  XtSetArg ( args[ arg_count ], XmNeditMode, XmMULTI_LINE_EDIT );
  arg_count++;
  XtSetArg ( args[ arg_count ], XmNeditable, False );
  arg_count++;
  msgtext = XmCreateText ( mainw,
			   "msgtext",
			   args,
			   arg_count );
  XtManageChild ( msgtext );

  /*
   * Set the various areas for the main window. Also, since we are using
   * a scrolled text widget, we do not need the Main Window's scrollbars
   * so unmanage them as well.
   */
  XtVaSetValues ( mainw,
		  XmNmessageWindow, msgtext,
		  XmNworkWindow, form,
		  XmNshowSeparator, True,
		  NULL );
  XtVaGetValues ( mainw,
		  XmNhorizontalScrollBar, &temp_id_hs,
		  XmNverticalScrollBar, &temp_id_vs,
		  NULL );
  XtUnmanageChild ( temp_id_hs );
  XtUnmanageChild ( temp_id_vs ); 
  XtManageChild ( form );
/*
  XtUnmanageChild ( XtNameToWidget ( mainw, "*HorScrollBar" ) );
  XtUnmanageChild ( XtNameToWidget ( mainw, "*VertScrollBar" ) );
*/
  /*
   * Create (but don't manage) a file selection box. This dialog will be
   * used to get filenames for read and save operations.
   */
  arg_count = 0;
  XtSetArg ( args[ arg_count ], XmNautoUnmanage, True );
  arg_count++;
  filesb = XmCreateFileSelectionDialog ( toplevel,
					 "filesb",
					 args,
					 arg_count );
  XtAddCallback ( filesb, XmNokCallback, filesbButtonCallback, (XtPointer) okButton );
  XtAddCallback ( filesb, XmNcancelCallback, filesbButtonCallback, (XtPointer) cancelButton );

  XtManageChild ( mainw );
}


/*
 * procedure    :   main - The main routine. This is where it all begins.
 *
 * arguments    :   argc (in / (int)) - number of command line arguments.
 *                  argv (in / (char **)) - pointer to the argument strings.
 *
 * return       :   (int) - status value. success/failure of program
 *
 * side effects : lots
 */

int main ( int argc, char *argv[] )
{
  /*
   * In case the app-defaults file is not there, these resources will make
   * the application usable.
   */
  String fallbacks[] = { "Scrolledtext*separate.shadowThickness: 3",
			 "Scrolledtext*separate.SeparatorType: SHADOW_ETCHED_IN_DASH",
			 "Scrolledtext*separate.topOffset: 5",
			 "Scrolledtext*scrolledtext.rows: 24",
			 "Scrolledtext*scrolledtext.columns: 80",
			 "Scrolledtext*scrolledtextSW.scrollingPolicy: AUTOMATIC",
			 "Scrolledtext*scrolledtextSW.visualPolicy: CONSTANT",
			 "Scrolledtext*scrolledtextSW.scrollBarDisplayPolicy: AS_NEEDED",
			 "Scrolledtext*button_1.labelString: Open",
			 "Scrolledtext*button_2.labelString: Save",
			 "Scrolledtext*button_3.labelString: Quit",
			 "Scrolledtext*filesb.dialogTitle: File Open/Save dialog",
			 (char *) NULL };
  toplevel = XtAppInitialize ( &app_context,  /* Application context */
			       "Scrolledtext",   /* Application class string */
			       NULL,          /* Options */
			       0,             /* Number of Options */
			       &argc,         /* Command line arg cnt in/out */
			       argv,          /* Command line args in/out */
			       fallbacks,     /* Fallback (last chance) resources */
			       NULL,          /* Arguments */
			       0 );           /* Number of Arguments */

  init_widgets ();               /* Build the interface                      */

  fileop = none;                 /* Currently not reading or saving any file */

  XtRealizeWidget ( toplevel );  /* Realize the widgets (i.e. create
					 the widget data structures */
  XtAppMainLoop ( app_context ); /* Jump into the main loop.
					 This never returns. */

}

This User Gave Thanks to Sennenmut For This Post:
# 2  
Old 10-25-2019
I think you need to change the font size in X/Motif, not in this application (text editor).

See, for example, the Motif Programming Manual (Volume 6A)

Motif Programming Manual (Volume 6A): 25 - Compound Strings

Quote:
This chapter describes Motif's technology for encoding font changes and character directions in the strings that are used by almost all of the Motif widgets.
# 3  
Old 10-25-2019
Yeah , has someone experience in that and can give any step by step advice what to do.
The whole Motif manual is to much information in detail.
Just want to RUN greater text in the Editor.
That would help.
# 4  
Old 10-25-2019
Maybe check out the examples for changing font size for the MWM:

Chapter 5. Customizing the Motif Window Manager
# 5  
Old 10-25-2019
Code:
.XDefaults/.Xresources

# 6  
Old 10-25-2019
.XDefaults/.Xresources

Hi , i cannot find the files.
Have written

find / Xdefaults
find / Xresources

not there.

--- Post updated at 12:55 PM ---

i found /etc/x11/app-defaults/ FOLDER with some files like XFontSel XLoad Xgc and many others
# 7  
Old 10-25-2019
Its too cumbersome.
I only want to make the font greater in this source code. Nothing else.
The ressource files are not there.
There are different places and names where they be.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Send mail with font change

Hi All, I have a file that contains following entries. I want to highlight the line that has word as "FAILURE" while sending the email. File ------------------------------------------------------------ Job Name: ABC Start Time: 07/20/2019 07:32:39 End Time: 07/20/2019... (4 Replies)
Discussion started by: sdosanjh
4 Replies

2. UNIX for Dummies Questions & Answers

Change font

how do i change from employee= to employee= in ksh. in my shell script, i just want to employee= to BOLD. (3 Replies)
Discussion started by: lawsongeek
3 Replies

3. Programming

Change font in Motif

Does anyone know how to change the font size into a larger one, in a basic Motif application? (1 Reply)
Discussion started by: JenniferKuiper
1 Replies

4. Shell Programming and Scripting

Change the font of text in output file in shell scipt

hi, I want to change the font of text in output file. :( I tried the below code code: if awk 'BEGIN{if('$RSS'>='1000')exit 0;exit 1}' then RED=`echo "\033 i can see colors in terminal but not in output file :wall: please help me how i can get colors text in output file. edit... (1 Reply)
Discussion started by: sreelu
1 Replies

5. Shell Programming and Scripting

how to change font in mailx

I am writing sql reports to an oracle database, spooling them to a file and emailing them with mailx. I use the syntax below. The reports do not format properly, unless I use the Courier New font. How do I set this with mailx? mailx -s "MY REPORT, `date +'%D %r` " -r "REPORTING SYSTEM"... (2 Replies)
Discussion started by: guessingo
2 Replies

6. Shell Programming and Scripting

change the font size in bash

Hi, I would like to change the font size in bash. I know how do it in ksh: F_VDOBLE="\033#6" print "${F_VDOBLE}Esto es..." But in bash I don't know Could you help me please? Many thanks! (5 Replies)
Discussion started by: mierdatuti
5 Replies

7. UNIX for Dummies Questions & Answers

How to change the font or color of text

Hi Gurus, I have a small requirement where i want to change the color & font of some text in a file. i have a file error.txt which will be created in the script using egrep. After that iam adding these lines at head & tail to that file using the following code awk 'BEGIN{print"Please... (4 Replies)
Discussion started by: pssandeep
4 Replies

8. Shell Programming and Scripting

Font Color Change Using .profile

Does anyone know how can I change font color, background color etc for a particular user using .profile? Any help is appreciated. (0 Replies)
Discussion started by: fifo_vs_lifo23
0 Replies

9. Shell Programming and Scripting

How to change the font colour in unix ?

Could you pls tell me how to change the font colour in unix ? What is the syntax ? (3 Replies)
Discussion started by: sars
3 Replies

10. Shell Programming and Scripting

Hw to change the font of output in perl

Hw to change the font color and size of output in perl (2 Replies)
Discussion started by: trupti_rinku
2 Replies
Login or Register to Ask a Question