1
0
mirror of https://github.com/arduino/Arduino.git synced 2024-11-29 10:24:12 +01:00
Commit Graph

1448 Commits

Author SHA1 Message Date
Matthijs Kooijman
6b31cffaec Add getTabs() and getCurrentTabIndex() to Editor and use them
Previously, some of the GUI code would use Editor.getSketch() to get the
current sketch, and Sketch.getCurrentCode() to find out the currently
selected tab. Since this code is really concerned with the currently
open tab in the GUI, it makes more sense to query the Editor tabs list
directly.

This removes all references the current sketch code, as tracked by
Sketch, external to Sketch itself. This prepares for removing the
current tab tracking from Sketch later.
2016-08-26 16:42:44 +02:00
Matthijs Kooijman
ca573351bb Do not store file contents in SketchCode
Now that each file in the sketch has its own text area in the GUI, it is
no longer needed to store the (possibly modified) contents of each file
inside SketchCode. Keeping the contents in the text area is sufficient.
Doing so allows removing the code that dealt with copying contents from
the text area into the SketchCode instance at the right time, which was
fragile and messy.

However, when compiling a sketch, the current (modified) file contents
still should be used. To allow this, the TextStorage interface is
introduced. This is a simple interface implemented by EditorTab, that
allows the SketchCode class to query the GUI for the current contents.
By using an interface, there is no direct dependency on the GUI code. If
no TextStorage instance is attached to a SketchCode, it will just assume
that the contents are always unmodified and the contents from the file
will be used during compilation.

When not using the GUI (e.g. just compiling something from the
commandline), there is no need to load the file contents from disk at
all, the filenames just have to be passed to arduino-builder and the
compiler. So, the SketchCode constructor no longer calls its `load()`
function, leaving this to the GUI code to call when appropriate. This
also modifies the `SketchCode.load()` function to return the loaded
text, instead of storing it internally.

To still support adding new files to a sketch (whose file does not
exist on disk yet), the EditorTab constructor now allows an initial
contents to be passed in, to be used instead of loading from disk. Only
the empty string is passed for new files now, but this could also be
used for the bare minimum contents of a new sketch later (which is now
down by creating a .ino file in a temporary directory).

Another side effect of this change is that all changes to the contents
now happen through the text area, which keeps track of modifications
already. This allows removing all manual calls to `Sketch.setModified()`
(even more, the entire function is removed, making `Sketch.isModified()`
always check the modification status of the contained files).
2016-08-26 16:42:44 +02:00
Matthijs Kooijman
422c111d81 Let EditorTab listen for changes to the text area
Previously, EditorTab set the Document on the SketchCodeDocument, and
the latter would listen for changes, only forwarding the modified status
to SketchCode. This commit cuts out a step and lets EditorTab call
SketchCode::setModified directly.

Additionally, the DocumentTextChangedListener helper class is added,
which wraps a simple (lambda) function to be called whenever anything
about the document text is modified. This hides the verbosity of having
to handle both insertion and deletion, and instead suffices with just
having a single lambda function instead.
2016-08-26 16:42:44 +02:00
Matthijs Kooijman
982d4f3fbf Use a separate RSyntaxTextArea for each editor tab
RSyntaxTextArea appears to support using a single instance and replacing
the underlying text and document when switching between tabs, but in
practice this support is not complete and even though the
RSyntaxTextArea developers did some work to improve the situation, they
recommend to just use a seperate instance for each tab.

This commit implements exactly that. A new class EditorTab is introduce
to wrap the RSyntaxTextArea and containing scroll pane, and to
encapsulate the code related to handling the text area itself. Doing so
removes some quirks and prepares for some later additions. In
particular, error highlights are now no longer shared between all tabs,
which was previously the case.

This commit mostly moves code from Editor into EditorTab, and updates
the callers to use getCurrentTab() and call methods on the result
instead of calling them on Editor. Some code is added to take care of
creating multiple EditorTab objects and switching between them. Some
small changes have been made to make the flow of opening files work,
though these are mostly a bit hacky.

While moving code, changes to the rest of the code were kept minimal,
retaining existing interfaces as much as possible. This sometimes result
in less than ideal code, which should be cleaned up in subsequent
commits.

The SketchCodeDocument class has been pretty much emptied out, since
it was mostly used to store things for tabs in the background, which are
now just stored in each RSyntaxTextArea separately. The last remaining
bits of this class can probably be moved or implemented differently
later, so it can be removed.

The entire flow of working with sketches and files needs to be cleaned
up next, so no thorough attempt at testing this commit was done. It is
likely that there are plenty of corner cases and race conditions, which
will be fixed once the reset of the code is cleaned up.

Fixes #3441
2016-08-26 16:42:44 +02:00
Matthijs Kooijman
c945b6c30a Let EditorToolbar use the global KeyboardFocusManager
For some toolbar buttons, when it is clicked while shift is pressed, its
function changes. When handling the click event, this information is
directly taken from KeyEvent.isShiftDown(). However, to also show the
proper tooltip *before* clicking, EditorToolbar listened to key events
on the main text area, to know when shift is (not) pressed.

This approach means that pressing shift while the text area is not
focused will not change the tooltip, and creates some unwanted coupling
between the toolbar and the text area.

This commit changes this approach to instead use the global
KeyboardFocusManager. Any key presses pass through there before being
dispatched to the currently focused component, so this makes sure that
any shift presses are caught, as well as making EditorToolbar a bit more
self-contained.
2016-08-26 16:42:44 +02:00
Cristian Maglie
d6db1deef0 Update revision log 2016-08-17 17:24:04 +02:00
Cristian Maglie
59e7c9ef60 Revert "Improve Examples menu"
This reverts commit 7235f9dc15.
2016-08-17 17:08:21 +02:00
Cristian Maglie
b583697e0b Revert "Only sort ideLibs if it's not empty"
This reverts commit 9b324bc9cc.
2016-08-17 17:08:14 +02:00
Cristian Maglie
4c6d2f4a82 Added new languages ach, kk and te 2016-08-16 13:16:38 +02:00
Cristian Maglie
aea77c889d Fixed some simple warnings 2016-08-16 12:52:24 +02:00
Cristian Maglie
49b98959c5 Correctly handle "-snapshot" and "+build" in semantic versioning
This fix a regression introduced in:

048a8a61 (VersionHelper now correctly strip snapshot info)

actually neither 048a8a61 nor the version before are correct becuase:

048a8a61 - strips all the extra `-snapshot` and `+build`
previous - doesn't handle the case `x.y-snapshot`

Now both are handled correctly and a test has been added to verify this.

To be completely semver compliant we should deny versions in the
format `x.y`, but this will break all legacy version that have been
published until now, so this changed should be postponed for the next
major release of the IDE.

Fix #5251
2016-08-16 11:00:35 +02:00
Cristian Maglie
eee54f1b3a Merge branch 'examplesmenu' of git://github.com/PaulStoffregen/Arduino into HEAD 2016-08-12 17:21:24 +02:00
Cristian Maglie
7008f6c57c ContributionsIndexer now has bundled hardware path as a field 2016-08-11 10:57:05 +02:00
PaulStoffregen
9b324bc9cc Only sort ideLibs if it's not empty 2016-08-02 02:43:04 -07:00
PaulStoffregen
7235f9dc15 Improve Examples menu 2016-07-28 16:58:28 -07:00
Sandeep Mistry
1a6be715ab Merge pull request #4794 from facchinm/upload_fail_handling
Handling gracefully upload failure
2016-07-20 10:18:57 -04:00
Sandeep Mistry
afe204f97f Merge pull request #4828 from facchinm/issue_4762
Filter examples based on contributed libraries by architecture
2016-07-19 10:00:18 -04:00
Cristian Maglie
8f20f4d98b "Include library" now checks for includes property
A new property "includes" has been added to library.properties.
This property contains a comma-separated list of the files to be included when
the user selects the "Include library" command on the Arduino IDE.

If the property is missing the old behaviour is used.
2016-06-23 13:04:56 +02:00
Martino Facchin
93578cef42 Fix ssh authentication on newer ssh clients
For Console monitor on network ports
2016-04-15 10:00:41 +02:00
Cristian Maglie
60b169fbe9 Merge branch 'ctrlDeleteBehavior' of https://github.com/avargas-nearsoft/Arduino 2016-04-07 11:32:46 +02:00
Martino Facchin
f6880fe617 Merge pull request #4792 from facchinm/solve_serial_windows
Rework serial ports handling
2016-04-06 18:03:45 +02:00
Arturo Vargas
a70bab3ea0 Add suport for OSX (ALT+DELETE) 2016-04-06 08:25:39 -07:00
Martino Facchin
c28c854936 Filter examples based on contributed libraries by architecture
Solves #4762
2016-04-06 14:41:12 +02:00
Cristian Maglie
f74afc4ad9 Remove incorrect Ctrl+K / Ctrl+W bindings
for a better explanation see @nopdotcom comment here:
https://github.com/arduino/Arduino/pull/4743#issuecomment-201447876
2016-04-06 12:18:45 +02:00
Jay Carlson
02914d79b9 Add more of OS X's native Emacs keybindings
OS X supports many simple Emacs keybindings in native text fields. (It
can do this because the system UI uses Cmd instead of Ctrl as its main
modifier key.) Add bindings to functions which already exist in
DefaultEditorKit.

I have a Ctrl-k (cut to end of line) implementation, but it is an
additional static RecordableTextAction class. I have not included it.
2016-04-06 12:17:58 +02:00
Cristian Maglie
050e8ba304 Merge branch 'cut/copyEnabled' of https://github.com/avargas-nearsoft/Arduino 2016-04-06 12:09:04 +02:00
Arturo Vargas
3efcc9ec48 Change the CTRL+DELETE behavior to restore the next word 2016-04-04 14:42:40 -07:00
Ivan Esparza
9c583829de Fixes issue 4440 2016-04-04 16:53:46 +02:00
Cristian Maglie
0c453355f4 Merge branch 'fix-annoying-popup' 2016-04-04 13:34:14 +02:00
Cristian Maglie
8d7ee63c70 Autoclose notification popup after 10 seconds. 2016-04-04 13:30:42 +02:00
Martino Facchin
84fdb0c0c3 Remove stray debug print 2016-04-01 17:05:54 +02:00
Martino Facchin
84ebc68af7 Handle case with empty error message 2016-04-01 12:06:32 +02:00
Martino Facchin
63de1cccfb Avoid generating an exception if upload fails
The current method of reporting upload errors is based on an exoteric combination of exceptions which makes return error code useless
The Uploader.java message() implementation is too avrdude-dependant to allow easy portability since the upload tools are becoming a lot and very different

With this commit we try to avoid exceptions and only use the external uploader's exit code to decide the status bar message.
The message can be:
- the last line containing "error" string (any case) or
- the usual avrdude message parsing (to keep compatibility with translations)

Needs testing with all platform and all supported upload tools
2016-04-01 12:06:21 +02:00
Martino Facchin
52ef55380d avoid NPE if serial monitor is waiting too long for opening 2016-04-01 11:38:53 +02:00
Martino Facchin
821c665460 Change message if requiring infos from Network port 2016-04-01 11:38:53 +02:00
Martino Facchin
243fc68763 Rework Serial ports handling and add Board info menu
This commit introduces the concept of stateful board list (vs. original stateless) and board serial number.

The board is now an "entity" composed by the triplet port/vid/pid. These informations come from libListSerial "light" function. When the board list changes, it triggers a request for the additional infos to libListSerial. These information contains the serial number of the boards.

These brings a lighter and faster scanning process. Some logic has been introduced to handle a board with the S/N only exposed in the bootloader (like 32u4).
In this case the disappearing port acquires the bootloader's S/N

A menu (under Ports menu) shows the currently connected port info and can be used for bugreporting
2016-04-01 11:38:53 +02:00
Martino Facchin
6d5597b070 Avoid multiple concurrent compile/upload operations
Disable Compile/Run buttons as they get press, and reenable only on function exit.
The launched upload process has now a 2minutes timeout before being terminated forcefully.
10 second after pressing "Upload" the button comes pressable again, but this time the previous upload command gets killed explicitely
2016-04-01 11:38:52 +02:00
Martino Facchin
b99ab40ba2 Enable links to directly open Lib/Board manager
If a sketch contains a link to http://librarymanager/${dropdown}#${filter} or http://boardmanager/${dropdown}#${filter} (for example http://librarymanager/All#OneWire) Library or Board manager will be opened applying the secified filters
2016-04-01 10:55:35 +02:00
Martino Facchin
a329731525 use hi-res icons for serial monitor and plotter
fixes #4701
2016-04-01 10:55:04 +02:00
Arturo Vargas
baa8a6e8a3 Disable cut and copy if there is not selected text 2016-03-31 15:11:20 -07:00
Cristian Maglie
1a7eaaf8b2 Fix always-on-top notification popup 2016-03-31 18:49:44 +02:00
Ivan Esparza
bbf909fd4f Changed color of version text in About box 2016-03-22 12:28:33 -07:00
agdl
057bf6391d This fixes #4572 2016-02-29 09:26:40 +01:00
Cristian Maglie
b02ce54387 Removed leftover stub for testing NotificationPopup dialog 2016-02-01 10:18:41 +01:00
Cristian Maglie
8e4ce4cfd1 Serial monitor font is scaled too 2016-02-01 10:14:19 +01:00
Cristian Maglie
5642c291d7 Fixed default initial editor size 2016-01-26 17:11:53 +01:00
Cristian Maglie
639d991dad Some small cosmetics 2016-01-26 17:11:53 +01:00
Cristian Maglie
57c6d096f6 Notification pop-up is now correctly scaled 2016-01-26 16:48:14 +01:00
Cristian Maglie
4659c6f985 Auto-scale editor and console fonts as well 2016-01-26 16:48:14 +01:00
Cristian Maglie
59ec660c9b Fixed minimum size for a bunch of GUI elements 2016-01-26 12:10:12 +01:00