forked from qunying/rhide
-
Notifications
You must be signed in to change notification settings - Fork 0
/
openedit.cc
108 lines (97 loc) · 2.22 KB
/
openedit.cc
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
/* Copyright (C) 1996-2000 Robert H”hne, see COPYING.RH for details */
/* This file is part of RHIDE. */
#include <unistd.h>
#define Uses_MsgBox
#define Uses_TApplication
#define Uses_TDirList
#define Uses_tvutilCommands
#define Uses_tvutilFunctions
#define Uses_TIDEEditWindow
#define Uses_TProject
#define Uses_TOptions
#define Uses_ideFunctions
#include <libide.h>
#include <libtvuti.h>
#include <rhutils.h>
#include "rhide.h"
#include "ideapp.h"
// This is for the Ctrl+ENTER feature
void
OpenFileFromEditor(char *name)
{
char *sname;
TCEditWindow *ewindow = NULL;
string_dup(sname, name);
FExpand(sname);
ewindow = is_on_desktop(sname);
if (!ewindow)
{
if (!__file_exists(name))
{
char *_sname, *arg = NULL;
char *bname;
BaseName(name, bname);
string_cat(arg, "$(word 1,$(foreach dir,$(RHIDE_STANDARD_INCLUDES),\
$(wildcard $(dir)/", bname, ")))", NULL);
_sname = expand_rhide_spec(arg);
if (*_sname)
{
string_free(sname);
sname = _sname;
}
else
string_free(_sname);
string_free(bname);
string_free(arg);
}
if (messageBox(mfConfirmation | mfYesButton | mfNoButton,
_("Open the file %s"), sname) == cmYes)
{
ewindow = ((IDE *) TProgram::application)->openEditor(sname, True);
}
}
string_free(sname);
if (ewindow)
ewindow->select();
}
void
OpenEditor(const char *name, Boolean search, TCEditWindow * &ew)
{
ew = OpenEditor(name, search);
if (ew)
AddReference((TWindow **) & ew);
}
TCEditWindow *
OpenEditor(const char *name, Boolean search)
{
char *sname;
TCEditWindow *ewindow;
if (search == True)
{
if (FindFile(name, sname) == False && UseRCS)
{
char *rcs_name = NULL;
char *_sname = NULL;
if (FindRCSFile(name, rcs_name, _sname) == True)
{
CheckoutRCSFile(rcs_name, sname, 1);
string_free(rcs_name);
string_free(sname);
sname = _sname;
}
}
}
else
{
string_dup(sname, name);
FExpand(sname);
}
ewindow = is_on_desktop(sname);
if (!ewindow)
{
ewindow = ((IDE *) TProgram::application)->openEditor(sname, True);
}
string_free(sname);
ewindow->select();
return ewindow;
}