Welcome to mirror list, hosted at ThFree Co, Russian Federation.

text_header.c « space_text « editors « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8150806619901a602434f4f9181b9f9b475ef3d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
/**
 * $Id$
 *
 * ***** BEGIN GPL LICENSE BLOCK *****
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version. 
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * The Original Code is Copyright (C) 2008 Blender Foundation.
 * All rights reserved.
 *
 * 
 * Contributor(s): Blender Foundation
 *
 * ***** END GPL LICENSE BLOCK *****
 */

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

/* file time checking */
#include <ctype.h>
#include <sys/types.h>
#include <sys/stat.h>

#ifndef _WIN32
#include <unistd.h>
#else
#include <io.h>
#include "BLI_winstuff.h"
#endif

#include "DNA_space_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_text_types.h"
#include "DNA_windowmanager_types.h"

#include "MEM_guardedalloc.h"

#include "BLI_blenlib.h"

#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_screen.h"
#include "BKE_text.h"

#include "ED_screen.h"
#include "ED_types.h"
#include "ED_util.h"

#include "WM_api.h"
#include "WM_types.h"

#include "BIF_gl.h"
#include "BIF_glutil.h"

#include "UI_interface.h"
#include "UI_resources.h"
#include "UI_view2d.h"

#include "RNA_access.h"

#ifndef DISABLE_PYTHON
#include "BPY_extern.h"
// XXX #include "BPY_menus.h"
#endif

#include "text_intern.h"

#define HEADER_PATH_MAX	260

/* ************************ header area region *********************** */

#ifndef DISABLE_PYTHON
static void do_text_template_scriptsmenu(bContext *C, void *arg, int event)
{
	// XXX BPY_menu_do_python(PYMENU_SCRIPTTEMPLATE, event);
}

static uiBlock *text_template_scriptsmenu(bContext *C, void *args_unused)
{
	ARegion *ar= CTX_wm_region(C);
	uiBlock *block;
	// XXX BPyMenu *pym;
	// int i= 0;
	// short yco = 20, menuwidth = 120;
	
	block= uiBeginBlock(C, ar, "text_template_scriptsmenu", UI_EMBOSSP);
	uiBlockSetButmFunc(block, do_text_template_scriptsmenu, NULL);
	
	/* note that we acount for the N previous entries with i+20: */
	/* XXX for (pym = BPyMenuTable[PYMENU_SCRIPTTEMPLATE]; pym; pym = pym->next, i++) {
		
		uiDefIconTextBut(block, BUTM, 1, ICON_PYTHON, pym->name, 0, yco-=20, menuwidth, 19, 
						 NULL, 0.0, 0.0, 1, i, 
						 pym->tooltip?pym->tooltip:pym->filename);
	}*/
	
	uiBlockSetDirection(block, UI_RIGHT);
	uiTextBoundsBlock(block, 60);

	uiEndBlock(C, block);
	uiDrawBlock(C, block);
	
	return block;
}

static void do_text_plugin_scriptsmenu(bContext *C, void *arg, int event)
{
	// XXX BPY_menu_do_python(PYMENU_TEXTPLUGIN, event);
}

static uiBlock *text_plugin_scriptsmenu(bContext *C, void *args_unused)
{
	ARegion *ar= CTX_wm_region(C);
	uiBlock *block;
	// XXX BPyMenu *pym;
	// int i= 0;
	// short yco = 20, menuwidth = 120;
	
	block= uiBeginBlock(C, ar, "text_plugin_scriptsmenu", UI_EMBOSSP);
	uiBlockSetButmFunc(block, do_text_plugin_scriptsmenu, NULL);
	
	/* note that we acount for the N previous entries with i+20: */
	/* XXX for (pym = BPyMenuTable[PYMENU_TEXTPLUGIN]; pym; pym = pym->next, i++) {
		
		uiDefIconTextBut(block, BUTM, 1, ICON_PYTHON, pym->name, 0, yco-=20, menuwidth, 19, 
						 NULL, 0.0, 0.0, 1, i, 
						 pym->tooltip?pym->tooltip:pym->filename);
	}*/
	
	uiBlockSetDirection(block, UI_RIGHT);
	uiTextBoundsBlock(block, 60);

	uiEndBlock(C, block);
	uiDrawBlock(C, block);

	return block;
}
#endif

static void text_editmenu_viewmenu(bContext *C, uiMenuItem *head, void *arg_unused)
{
	uiMenuItemEnumO(head, "Top of File", 0, "TEXT_OT_move", "type", FILE_TOP);
	uiMenuItemEnumO(head, "Bottom of File", 0, "TEXT_OT_move", "type", FILE_BOTTOM);
}

static void text_editmenu_selectmenu(bContext *C, uiMenuItem *head, void *arg_unused)
{
	uiMenuItemO(head, 0, "TEXT_OT_select_all");
	uiMenuItemO(head, 0, "TEXT_OT_select_line");
}

static void text_editmenu_markermenu(bContext *C, uiMenuItem *head, void *arg_unused)
{
	uiMenuItemO(head, 0, "TEXT_OT_markers_clear");
	uiMenuItemO(head, 0, "TEXT_OT_next_marker");
	uiMenuItemO(head, 0, "TEXT_OT_previous_marker");
}

static void text_formatmenu(bContext *C, uiMenuItem *head, void *arg_unused)
{
	uiMenuItemO(head, 0, "TEXT_OT_indent");
	uiMenuItemO(head, 0, "TEXT_OT_unindent");

	uiMenuSeparator(head);

	uiMenuItemO(head, 0, "TEXT_OT_comment");
	uiMenuItemO(head, 0, "TEXT_OT_uncomment");

	uiMenuSeparator(head);

	uiMenuLevelEnumO(head, "TEXT_OT_convert_whitespace", "type");
}

static void text_editmenu_to3dmenu(bContext *C, uiMenuItem *head, void *arg_unused)
{
	uiMenuItemBooleanO(head, "One Object", 0, "TEXT_OT_to_3d_object", "split_lines", 0);
	uiMenuItemBooleanO(head, "One Object Per Line", 0, "TEXT_OT_to_3d_object", "split_lines", 1);
}

static int text_menu_edit_poll(bContext *C)
{
	return (CTX_data_edit_text(C) != NULL);
}

static void text_editmenu(bContext *C, uiMenuItem *head, void *arg_unused)
{
	uiMenuItemO(head, 0, "ED_OT_undo");
	uiMenuItemO(head, 0, "ED_OT_redo");

	uiMenuSeparator(head);

	uiMenuItemO(head, 0, "TEXT_OT_cut");
	uiMenuItemO(head, 0, "TEXT_OT_copy");
	uiMenuItemO(head, 0, "TEXT_OT_paste");

	uiMenuSeparator(head);

	uiMenuLevel(head, "View", text_editmenu_viewmenu);
	uiMenuLevel(head, "Select", text_editmenu_selectmenu);
	uiMenuLevel(head, "Markers", text_editmenu_markermenu);

	uiMenuSeparator(head);

	uiMenuItemO(head, 0, "TEXT_OT_jump");
	uiMenuItemO(head, 0, "TEXT_OT_properties");

	uiMenuSeparator(head);

	uiMenuLevel(head, "Text to 3D Object", text_editmenu_to3dmenu);
}

static void text_filemenu(bContext *C, uiMenuItem *head, void *arg_unused)
{
	SpaceText *st= (SpaceText*)CTX_wm_space_data(C);
	Text *text= st->text;

	uiMenuItemO(head, 0, "TEXT_OT_new");
	uiMenuItemO(head, 0, "TEXT_OT_open");
	
	if(text) {
		uiMenuItemO(head, 0, "TEXT_OT_reload");
		
		uiMenuSeparator(head);
		
		uiMenuItemO(head, 0, "TEXT_OT_save");
		uiMenuItemO(head, 0, "TEXT_OT_save_as");
		
		if(text->name)
			uiMenuItemO(head, 0, "TEXT_OT_make_internal");

		uiMenuSeparator(head);
		
		uiMenuItemO(head, 0, "TEXT_OT_run_script");

#ifndef DISABLE_PYTHON
		if(BPY_is_pyconstraint(text))
			uiMenuItemO(head, 0, "TEXT_OT_refresh_pyconstraints");
#endif
	}

#ifndef DISABLE_PYTHON
	// XXX uiMenuSeparator(head);

	// XXX uiDefIconTextBlockBut(block, text_template_scriptsmenu, NULL, ICON_RIGHTARROW_THIN, "Script Templates", 0, yco-=20, 120, 19, "");
	// XXX uiDefIconTextBlockBut(block, text_plugin_scriptsmenu, NULL, ICON_RIGHTARROW_THIN, "Text Plugins", 0, yco-=20, 120, 19, "");
#endif
}

/*********************** datablock browse *************************/

static void text_unlink(Main *bmain, Text *text)
{
	bScreen *scr;
	ScrArea *area;
	SpaceLink *sl;

	/* XXX this ifdef is in fact dangerous, if python is
	 * disabled it will leave invalid pointers in files! */

#ifndef DISABLE_PYTHON
	// XXX BPY_clear_bad_scriptlinks(text);
	// XXX BPY_free_pyconstraint_links(text);
	// XXX free_text_controllers(text);

	/* check if this text was used as script link:
	 * this check function unsets the pointers and returns how many
	 * script links used this Text */
	if(0) // XXX BPY_text_check_all_scriptlinks (text))
		; // XXX notifier: allqueue(REDRAWBUTSSCRIPT, 0);

	/* equivalently for pynodes: */
	if(0) // XXX nodeDynamicUnlinkText ((ID*)text))
		; // XXX notifier: allqueue(REDRAWNODE, 0);
#endif
	
	for(scr= bmain->screen.first; scr; scr= scr->id.next) {
		for(area= scr->areabase.first; area; area= area->next) {
			for(sl= area->spacedata.first; sl; sl= sl->next) {
				if(sl->spacetype==SPACE_TEXT) {
					SpaceText *st= (SpaceText*) sl;
					
					if(st->text==text) {
						st->text= NULL;
						st->top= 0;
						
						if(st==area->spacedata.first)
							ED_area_tag_redraw(area);
					}
				}
			}
		}
	}

	free_libblock(&bmain->text, text);
}

static void text_idpoin_handle(bContext *C, ID *id, int event)
{
	SpaceText *st= (SpaceText*)CTX_wm_space_data(C);
	Text *text;

	switch(event) {
		case UI_ID_BROWSE:
			st->text= (Text*)id;
			st->top= 0;

			text_update_edited(st->text);
			WM_event_add_notifier(C, NC_TEXT|ND_CURSOR, st->text);

			ED_undo_push(C, "Browse Text");
			break;
		case UI_ID_DELETE:
			text= st->text;

			/* make the previous text active, if its not there make the next text active */
			if(text->id.prev) {
				st->text = text->id.prev;
				WM_event_add_notifier(C, NC_TEXT|ND_CURSOR, st->text);
			}
			else if(text->id.next) {
				st->text = text->id.next;
				WM_event_add_notifier(C, NC_TEXT|ND_CURSOR, st->text);
			}

			text_unlink(CTX_data_main(C), text);
			WM_event_add_notifier(C, NC_TEXT|NA_REMOVED, text);

			ED_undo_push(C, "Delete Text");
			break;
		case UI_ID_RENAME:
			break;
		case UI_ID_ADD_NEW:
			WM_operator_name_call(C, "TEXT_OT_new", WM_OP_INVOKE_REGION_WIN, NULL);
			break;
		case UI_ID_OPEN:
			WM_operator_name_call(C, "TEXT_OT_open", WM_OP_INVOKE_REGION_WIN, NULL);
			break;
	}
}

/********************** header buttons ***********************/

static void text_header_draw(const bContext *C, Header *header)
{
	bScreen *sc= CTX_wm_screen(C);
	SpaceText *st= (SpaceText*)CTX_wm_space_data(C);
	PointerRNA spaceptr;
	Text *text= st->text;
	uiLayout *layout= header->layout;
	
	RNA_pointer_create(&sc->id, &RNA_SpaceTextEditor, st, &spaceptr);

	uiTemplateHeaderMenus(layout);
	uiItemM(layout, "Text", 0, text_filemenu);
	if(text) {
		uiItemM(layout, "Edit", 0, text_editmenu);
		uiItemM(layout, "Format", 0, text_formatmenu);
	}

	/* warning button if text is out of date */
	if(text && text_file_modified(text)) {
		uiTemplateHeaderButtons(layout);
		uiTemplateSetColor(layout, TH_REDALERT);
		uiItemO(layout, "", ICON_HELP, "TEXT_OT_resolve_conflict");
	}

	uiTemplateHeaderButtons(layout);
	uiItemR(layout, "", ICON_LINENUMBERS_OFF, &spaceptr, "line_numbers", 0);
	uiItemR(layout, "", ICON_WORDWRAP_OFF, &spaceptr, "word_wrap", 0);
	uiItemR(layout, "", ICON_SYNTAX_OFF, &spaceptr, "syntax_highlight", 0);
	// XXX uiItemR(layout, "", ICON_SCRIPTPLUGINS, &spaceptr, "do_python_plugins", 0);

	uiTemplateHeaderID(layout, &spaceptr, "text",
		UI_ID_BROWSE|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE,
		text_idpoin_handle);

	/* file info */
	if(text) {
		char fname[HEADER_PATH_MAX];
		static char headtxt[HEADER_PATH_MAX+17];
		int len;

		if(text->name) {
			len = strlen(text->name);
			if(len > HEADER_PATH_MAX-1)
				len = HEADER_PATH_MAX-1;
			strncpy(fname, text->name, len);
			fname[len]='\0';
			if(text->flags & TXT_ISDIRTY)
				sprintf(headtxt, "File: *%s (unsaved)", fname);
			else
				sprintf(headtxt, "File: %s", fname);
		}
		else
			sprintf(headtxt, text->id.lib? "Text: External": "Text: Internal");

		uiTemplateHeaderButtons(layout);
		uiItemL(layout, headtxt, 0);
	}
}

void text_header_register(ARegionType *art)
{
	HeaderType *ht;

	/* header */
	ht= MEM_callocN(sizeof(HeaderType), "spacetype text header");
	strcpy(ht->idname, "TEXT_HT_header");
	ht->draw= text_header_draw;
	BLI_addhead(&art->headertypes, ht);
}

/************************** properties ******************************/

static void text_properties_panel_draw(const bContext *C, Panel *panel)
{
	bScreen *sc= CTX_wm_screen(C);
	SpaceText *st= CTX_wm_space_text(C);
	uiLayout *layout= panel->layout;
	PointerRNA spaceptr;
	
	RNA_pointer_create(&sc->id, &RNA_SpaceTextEditor, st, &spaceptr);

	uiLayoutColumn(layout);
	uiItemR(layout, NULL, ICON_LINENUMBERS_OFF, &spaceptr, "line_numbers", 0);
	uiItemR(layout, NULL, ICON_WORDWRAP_OFF, &spaceptr, "word_wrap", 0);
	uiItemR(layout, NULL, ICON_SYNTAX_OFF, &spaceptr, "syntax_highlight", 0);

	uiLayoutColumn(layout);
	uiItemR(layout, NULL, 0, &spaceptr, "font_size", 0);
	uiItemR(layout, NULL, 0, &spaceptr, "tab_width", 0);
}

static void text_find_panel_draw(const bContext *C, Panel *panel)
{
	bScreen *sc= CTX_wm_screen(C);
	SpaceText *st= CTX_wm_space_text(C);
	uiLayout *layout= panel->layout;
	PointerRNA spaceptr;
	
	RNA_pointer_create(&sc->id, &RNA_SpaceTextEditor, st, &spaceptr);

	/* find */
	uiLayoutRow(layout);
	uiItemR(layout, "", 0, &spaceptr, "find_text", 0);
	uiItemO(layout, "", ICON_TEXT, "TEXT_OT_find_set_selected");
	uiLayoutColumn(layout);
	uiItemO(layout, NULL, 0, "TEXT_OT_find");

	/* replace */
	uiLayoutRow(layout);
	uiItemR(layout, "", 0, &spaceptr, "replace_text", 0);
	uiItemO(layout, "", ICON_TEXT, "TEXT_OT_replace_set_selected");
	uiLayoutColumn(layout);
	uiItemO(layout, NULL, 0, "TEXT_OT_replace");

	/* mark */
	uiLayoutColumn(layout);
	uiItemO(layout, NULL, 0, "TEXT_OT_mark_all");

	/* settings */
	uiLayoutColumnFlow(layout, 0);
	uiItemR(layout, "Wrap", 0, &spaceptr, "find_wrap", 0);
	uiItemR(layout, "All", 0, &spaceptr, "find_all", 0);
}

void text_properties_register(ARegionType *art)
{
	PanelType *pt;

	/* panels: properties */
	pt= MEM_callocN(sizeof(PanelType), "spacetype text panel");
	strcpy(pt->idname, "TEXT_PT_properties");
	strcpy(pt->label, "Properties");
	pt->draw= text_properties_panel_draw;
	BLI_addtail(&art->paneltypes, pt);

	/* panels: find */
	pt= MEM_callocN(sizeof(PanelType), "spacetype text panel");
	strcpy(pt->idname, "TEXT_PT_find");
	strcpy(pt->label, "Find");
	pt->draw= text_find_panel_draw;
	BLI_addtail(&art->paneltypes, pt);
}

ARegion *text_has_properties_region(ScrArea *sa)
{
	ARegion *ar, *arnew;
	
	for(ar= sa->regionbase.first; ar; ar= ar->next)
		if(ar->regiontype==RGN_TYPE_UI)
			return ar;
	
	/* add subdiv level; after header */
	for(ar= sa->regionbase.first; ar; ar= ar->next)
		if(ar->regiontype==RGN_TYPE_HEADER)
			break;
	
	/* is error! */
	if(ar==NULL) return NULL;
	
	arnew= MEM_callocN(sizeof(ARegion), "properties region");
	
	BLI_insertlinkafter(&sa->regionbase, ar, arnew);
	arnew->regiontype= RGN_TYPE_UI;
	arnew->alignment= RGN_ALIGN_LEFT;
	
	arnew->flag = RGN_FLAG_HIDDEN;
	
	return arnew;
}

static int properties_poll(bContext *C)
{
	SpaceText *st= CTX_wm_space_text(C);
	Text *text= CTX_data_edit_text(C);

	return (st && text);
}

static int properties_exec(bContext *C, wmOperator *op)
{
	ScrArea *sa= CTX_wm_area(C);
	ARegion *ar= text_has_properties_region(sa);
	
	if(ar) {
		ar->flag ^= RGN_FLAG_HIDDEN;
		ar->v2d.flag &= ~V2D_IS_INITIALISED; /* XXX should become hide/unhide api? */
		
		ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), sa);
		ED_area_tag_redraw(sa);
	}

	return OPERATOR_FINISHED;
}

void TEXT_OT_properties(wmOperatorType *ot)
{
	/* identifiers */
	ot->name= "Properties";
	ot->idname= "TEXT_OT_properties";
	
	/* api callbacks */
	ot->exec= properties_exec;
	ot->poll= properties_poll;
}

/******************** XXX popup menus *******************/

#if 0
{
	// RMB

	uiMenuItem *head;

	if(text) {
		head= uiPupMenuBegin("Text", 0);
		if(txt_has_sel(text)) {
			uiMenuItemO(head, 0, "TEXT_OT_cut");
			uiMenuItemO(head, 0, "TEXT_OT_copy");
		}
		uiMenuItemO(head, 0, "TEXT_OT_paste");
		uiMenuItemO(head, 0, "TEXT_OT_new");
		uiMenuItemO(head, 0, "TEXT_OT_open");
		uiMenuItemO(head, 0, "TEXT_OT_save");
		uiMenuItemO(head, 0, "TEXT_OT_save_as");
		uiMenuItemO(head, 0, "TEXT_OT_run_script");
		uiPupMenuEnd(C, head);
	}
	else {
		head= uiPupMenuBegin("File", 0);
		uiMenuItemO(head, 0, "TEXT_OT_new");
		uiMenuItemO(head, 0, "TEXT_OT_open");
		uiPupMenuEnd(C, head);
	}
}

{
	// Alt+Shift+E

	uiMenuItem *head;

	head= uiPupMenuBegin("Edit", 0);
	uiMenuItemO(head, 0, "TEXT_OT_cut");
	uiMenuItemO(head, 0, "TEXT_OT_copy");
	uiMenuItemO(head, 0, "TEXT_OT_paste");
	uiPupMenuEnd(C, head);
}

{
	// Alt+Shift+F

	uiMenuItem *head;

	if(text) {
		head= uiPupMenuBegin("Text", 0);
		uiMenuItemO(head, 0, "TEXT_OT_new");
		uiMenuItemO(head, 0, "TEXT_OT_open");
		uiMenuItemO(head, 0, "TEXT_OT_save");
		uiMenuItemO(head, 0, "TEXT_OT_save_as");
		uiMenuItemO(head, 0, "TEXT_OT_run_script");
		uiPupMenuEnd(C, head);
	}
	else {
		head= uiPupMenuBegin("File", 0);
		uiMenuItemO(head, 0, "TEXT_OT_new");
		uiMenuItemO(head, 0, "TEXT_OT_open");
		uiPupMenuEnd(C, head);
	}
}

{
	// Alt+Shift+V

	uiMenuItem *head;

	head= uiPupMenuBegin("Text", 0);
	uiMenuItemEnumO(head, "Top of File", 0, "TEXT_OT_move", "type", FILE_TOP);
	uiMenuItemEnumO(head, "Bottom of File", 0, "TEXT_OT_move", "type", FILE_BOTTOM);
	uiMenuItemEnumO(head, "Page Up", 0, "TEXT_OT_move", "type", PREV_PAGE);
	uiMenuItemEnumO(head,  "Page Down", 0, "TEXT_OT_move", "type", NEXT_PAGE);
	uiPupMenuEnd(C, head);
}
#endif