1Padre::Current(3) User Contributed Perl Documentation Padre::Current(3)
2
3
4
6 Padre::Current - A context object, for centralising the concept of what
7 is "current"
8
10 The "Padre::Current" detectes and returns whatever is current. Use it
11 whenever you need to do something with anything which might get a focus
12 or be selectable otherwise
13
14 All methods could be called as functions, methods or class methods.
15
17 "config"
18 my $config = Padre::Current->config;
19
20 Returns a Padre::Config object for the current document.
21
22 Padre has three types of configuration: User-specific, host-specific
23 and project-specific, this method returnsa config object which includes
24 the current values - ne need to for you to care about which config is
25 active and which has priority.
26
27 "document"
28 my $document = Padre::Current->document;
29
30 Returns a Padre::Document object for the current document.
31
32 "editor"
33 my $editor = Padre::Current->editor;
34
35 Returns a Padre::Editor object for the current editor (containing the
36 current document).
37
38 "filename"
39 my $filename = Padre::Current->filename;
40
41 Returns the filename of the current document.
42
43 "ide"
44 my $ide = Padre::Current->ide;
45
46 Returns a Padre::Wx object of the current ide.
47
48 "main"
49 my $main = Padre::Current->main;
50
51 Returns a Padre::Wx::Main object of the current ide.
52
53 "notebook"
54 my $main = Padre::Current->notebook;
55
56 Returns a Padre::Wx::Notebook object of the current notebook.
57
58 "project"
59 my $main = Padre::Current->project;
60
61 Returns a Padre::Project object of the current project.
62
63 "text"
64 my $main = Padre::Current->text;
65
66 Returns the current selection (selected text in the current document).
67
68 "title"
69 my $main = Padre::Current->title;
70
71 Returns the title of the current editor window.
72
74 Padre::Current - convenient access to current objects within Padre
75
77 my $main = Padre::Current->main;
78 # ...
79
81 Padre uses lots of objects from different classes. And one needs to
82 have access to the current object of this sort or this other to do
83 whatever is need at the time.
84
85 Instead of poking directly with the various classes to find the object
86 you need, "Padre::Current" provides a bunch of handy methods to
87 retrieve whatever current object you need.
88
90 new
91 # Vanilla constructor
92 Padre::Current->new;
93
94 # Seed the object with some context
95 Padre::Current->new( document => $document );
96
97 The "new" constructor creates a new context object, it optionally takes
98 one or more named parameters which should be any context the caller is
99 aware of before he calls the constructor.
100
101 Providing this seed context allows the context object to derive parts
102 of the current context from other parts, without the need to fall back
103 to the last-resort "Padre->ide" singleton-fetching method.
104
105 Many objects in Padre that are considered to be part of them context
106 will have a "current" method which automatically creates the context
107 object with it as a seed.
108
109 Returns a new Padre::Current object.
110
111 "ide"
112 Return the Padre singleton for the IDE instance.
113
114 "config"
115 Returns the current Padre::Config configuration object for the IDE.
116
117 "main"
118 Returns the Padre::Wx::Main object for the main window.
119
120 "notebook"
121 Returns the Padre::Wx::Notebook object for the main window.
122
123 "document"
124 Returns the active Padre::Document document object.
125
126 "editor"
127 Returns the Padre::Editor editor object for the active document.
128
129 "filename"
130 Returns the file name of the active document, if it has one.
131
132 "title"
133 Return the title of current editor window.
134
135 "project"
136 Return the "Padre::Project" project object for the active document.
137
138 "text"
139 Returns the selected text, or a null string if nothing is selected.
140
142 Copyright 2008-2011 The Padre development team as listed in Padre.pm.
143
144 This program is free software; you can redistribute it and/or modify it
145 under the same terms as Perl itself.
146
147 The full text of the license can be found in the LICENSE file included
148 with this module.
149
150
151
152perl v5.32.0 2020-07-28 Padre::Current(3)